// Numbas version: exam_results_page_options {"variable_groups": [], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Find mean and standard deviation of differences between samples", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),5)", "description": "", "name": "r1"}, "thismany": {"templateType": "anything", "group": "Ungrouped variables", "definition": "5", "description": "", "name": "thismany"}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1.5..2.5#0.5)", "description": "", "name": "sig1"}, "performing": {"templateType": "anything", "group": "Ungrouped variables", "definition": " 'working at $\\\\var{100}$ watts on an exercise machine' ", "description": "", "name": "performing"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),5)", "description": "", "name": "r2"}, "attempt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'attempt'", "description": "", "name": "attempt"}, "meandiff": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(d)", "description": "", "name": "meandiff"}, "objects": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'people'", "description": "", "name": "objects"}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(16..20#0.5)", "description": "", "name": "mu1"}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1+random(-0.5..-0.2#0.1)", "description": "", "name": "sig2"}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu1+random(1..3#0.1)", "description": "", "name": "mu2"}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(r2)-vector(r1))", "description": "", "name": "d"}, "stdiff": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stdev(d,true),3)", "description": "", "name": "stdiff"}, "object": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'person'", "description": "", "name": "object"}, "something": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'Oxygen uptake values (mL/kg.min)'", "description": "", "name": "something"}}, "ungrouped_variables": ["meandiff", "performing", "attempt", "r1", "objects", "mu2", "object", "sig1", "thismany", "stdiff", "sig2", "something", "r2", "mu1", "d"], "functions": {}, "preamble": {"css": "", "js": ""}, "parts": [{"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "

Find the mean and standard deviation of the difference between first and second {attempt}s.

\n

Calculate differences for second {attempt} – first {attempt}.

\n

Mean of difference = [[0]] (input as an exact decimal)

\n

Standard deviation of difference = [[1]] (input to 3 decimal places)

", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "minValue": "{meandiff}", "maxValue": "{meandiff}", "unitTests": [], "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "scripts": {}, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "mustBeReducedPC": 0}, {"correctAnswerFraction": false, "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "minValue": "{stdiff}", "maxValue": "{stdiff}", "unitTests": [], "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "scripts": {}, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "mustBeReducedPC": 0}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}], "statement": "

{Something} for $\\var{thismany}$ {objects} {performing} were:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
{capitalise(object)}12345
First {attempt}$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$
Second {attempt}$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$
", "tags": ["checked2015", "cr1", "data analysis", "differences", "elementary statistics", "mean", "mean of differences", "standard deviation", "standard deviation of differences", "statistics", "stats", "tested1", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

An experiment is performed twice, each with $5$ outcomes

\n

$x_i,\\;y_i,\\;i=1,\\dots 5$ . Find mean and s.d. of their differences $y_i-x_i,\\;i=1,\\dots 5$.

"}, "type": "question", "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

The table of differences is given by:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
{capitalise(object)}12345
First {attempt}$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$
Second {attempt}$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$
Differences$\\var{d[0]}$$\\var{d[1]}$$\\var{d[2]}$$\\var{d[3]}$$\\var{d[4]}$
\n

The mean of the differences is $\\var{meandiff}$.

\n

The variance $V$ of the differences is

\n

\\begin{align}
V &= \\frac{1}{4}\\left(\\simplify[]{({d[0]}^2+{d[1]}^2+{d[2]}^2+{d[3]}^2+{d[4]}^2)}-5\\times \\var{meandiff}^2\\right) \\\\
&= \\var{variance(d,true)}
\\end{align}

\n

Hence the standard deviation is $\\sqrt{V}=\\var{stdiff}$ to 3 decimal places.

"}, {"name": "Find quartiles, range and interquartile range of small sample", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(4..9)", "description": "", "name": "sig"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sort(r0)", "description": "", "name": "r1"}, "median": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.5*(r1[15]+r1[16])", "description": "", "name": "median"}, "var": {"templateType": "anything", "group": "Ungrouped variables", "definition": "variance(r0,true)", "description": "", "name": "var"}, "guess2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round(guess1/4)", "description": "", "name": "guess2"}, "mean": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(r0)", "description": "", "name": "mean"}, "sd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "stdev(r0,true)", "description": "", "name": "sd"}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(30..50)", "description": "", "name": "mu"}, "uquartile": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.25*r1[23]+0.75*r1[24]", "description": "", "name": "uquartile"}, "guess4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round(7*guess1/4)", "description": "", "name": "guess4"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "32", "description": "", "name": "n"}, "guess1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round((r1[31]-r1[0])/4)", "description": "", "name": "guess1"}, "lquartile": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.75*r1[7]+0.25*r1[8]", "description": "", "name": "lquartile"}, "guess3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round(guess1/2)", "description": "", "name": "guess3"}, "range": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1[31]-r1[0]", "description": "", "name": "range"}, "r0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu,sig)),32)", "description": "", "name": "r0"}, "stdev": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stdev(r0,true),2)", "description": "", "name": "stdev"}}, "ungrouped_variables": ["guess3", "guess2", "guess1", "r0", "r1", "guess4", "mean", "median", "n", "mu", "lquartile", "sig", "stdev", "var", "uquartile", "sd", "range"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{r1[0]}", "minValue": "{r1[0]}", "correctAnswerFraction": false, "marks": 0.4, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{lquartile}", "minValue": "{lquartile}", "correctAnswerFraction": false, "marks": 0.4, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{median}", "minValue": "{median}", "correctAnswerFraction": false, "marks": 0.4, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{uquartile}", "minValue": "{uquartile}", "correctAnswerFraction": false, "marks": 0.4, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{r1[31]}", "minValue": "{r1[31]}", "correctAnswerFraction": false, "marks": 0.4, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n \n \n

Obtain the $5$ number summary MQMQM and input their values below as exact decimals:

\n \n \n \n \n \n \n \n \n \n
MinimumLower QuartileMedianUpper QuartileMaximum
[[0]][[1]][[2]][[3]][[4]]
\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "range", "minValue": "range", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Find the range as an exact decimal.

\n

Range=[[0]]

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{uquartile-lquartile}", "minValue": "{uquartile-lquartile}", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n \n \n

Enter the interquartile range: [[0]]

\n \n \n \n

Input as an exact decimal.

\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"displayType": "radiogroup", "choices": ["

{guess1}

", "

{guess2}

", "

{guess3}

", "

{guess4}

"], "displayColumns": 4, "distractors": ["", "", "", ""], "shuffleChoices": true, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": [1, 0, 0, 0], "marks": 0}], "type": "gapfill", "prompt": "

Without doing any further calculations, which of the following numbers do you think is likely to be closest to the sample standard deviation?
[[0]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "\n \n \n

Given the following table of data, answer all the following questions:

\n \n \n \n \n \n \n \n \n \n
$\\var{r0[0]}$$\\var{r0[1]}$$\\var{r0[2]}$$\\var{r0[3]}$$\\var{r0[4]}$$\\var{r0[5]}$$\\var{r0[6]}$$\\var{r0[7]}$$\\var{r0[8]}$$\\var{r0[9]}$$\\var{r0[10]}$$\\var{r0[11]}$$\\var{r0[12]}$$\\var{r0[13]}$$\\var{r0[14]}$$\\var{r0[15]}$
$\\var{r0[16]}$$\\var{r0[17]}$$\\var{r0[18]}$$\\var{r0[19]}$$\\var{r0[20]}$$\\var{r0[21]}$$\\var{r0[22]}$$\\var{r0[23]}$$\\var{r0[24]}$$\\var{r0[25]}$$\\var{r0[26]}$$\\var{r0[27]}$$\\var{r0[28]}$$\\var{r0[29]}$$\\var{r0[30]}$$\\var{r0[31]}$
\n \n \n ", "tags": ["average", "checked2015", "cr1", "data analysis", "interquartile range", "lower quartile", "MAS8380", "maximum", "mean", "mean ", "median", "minumum", "MQMQM", "ordered data", "quartile", "query", "sample standard deviation", "standard deviation", "tested1", "upper quartile"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

11/07/2012:

\n

Added tags.

\n

Calculations not tested yet.

\n

23/07/2012:

\n

Added description.

\n

Checked calculations as stats extension now available. OK.

\n

3/08/2012:

\n

Added tags.

\n

Question appears to be working correctly.

\n

19/12/2012:

\n

Changed to new stats functions and replaced the uniform sample data by a normal sample. 

\n

Checked calculations. Note that the quartiles are defined differently from the stats extension definition - so used the Newcastle definition! Added query tag so that can be decided upon.

\n

Added tested1 tag.

\n

21/12/2012:

\n

Rounding OK, added tag cr1.

\n

 

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Given 32 datapoints in a table find their minimum, lower quartile, median, upper quartile, and maximum.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

a)

\n

If you sort the data in increasing order you get the following table:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r1[10]}$$\\var{r1[11]}$$\\var{r1[12]}$$\\var{r1[13]}$$\\var{r1[14]}$$\\var{r1[15]}$
$\\var{r1[16]}$$\\var{r1[17]}$$\\var{r1[18]}$$\\var{r1[19]}$$\\var{r1[20]}$$\\var{r1[21]}$$\\var{r1[22]}$$\\var{r1[23]}$$\\var{r1[24]}$$\\var{r1[25]}$$\\var{r1[26]}$$\\var{r1[27]}$$\\var{r1[28]}$$\\var{r1[29]}$$\\var{r1[30]}$$\\var{r1[31]}$
\n

Denote the ordered data by $x_j$, thus $x_{10}=\\var{r1[9]}$ for example.

\n

Minimum value: The minimum value is $x_1=\\var{r1[0]}$.

\n

Lower Quartile: As there is an even number of values, the Lower Quartile will lie between two values. Its position is calculated by finding

\n

\\[\\frac{n+1}{4}=\\frac{\\var{n+1}}{4}=8\\frac{1}{4}\\]

\n

Hence the Lower Quartile lies between the 8th and 9th entries in the ordered table, so it is:

\n

\\[0.75\\times x_8+0.25\\times x_9 = 0.75\\times\\var{r1[7]}+0.25\\times \\var{r1[8]}=\\var{lquartile}\\]

\n

Median: The position of the median in the table is given by

\n

\\[ \\frac{2(n+1)}{4} = \\frac{\\var{2*(n+1)}}{4} = 16 \\frac{1}{2}\\]

\n

The median lies between the 16th and 17th entries in the ordered table and is given by:

\n

\\[0.5\\times x_{16}+0.5\\times x_{17} = 0.5\\times\\var{r1[15]}+0.5\\times \\var{r1[16]}=\\var{median}\\]

\n

Upper Quartile: As there is an even number of values, the Upper Quartile will lie between two values. Its position is calculated by finding

\n

\\[\\frac{3(n+1)}{4}=\\frac{\\var{3*(n+1)}}{4}=24\\frac{3}{4}\\]

\n

Hence the Upper Quartile lies between the 24th and 25th entries in the ordered table.

\n

We find it is \\[0.25\\times x_{24}+0.75\\times x_{25} = 0.25\\times\\var{r1[23]}+0.75\\times \\var{r1[24]}=\\var{uquartile}\\]

\n

Maximum value: The maximum value is $x_{32}=\\var{r1[31]}$

\n

b)

\n

The range is defined to be

Range = Maximum – Minimum

and so in this case we have:

Range = $\\var{r1[31]}-\\var{r1[0]}=\\var{range}$.

\n

c)

\n

The interquartile range is defined to be

\n

\\[ \\text{Upper Quartile} – \\text{Lower Quartile} \\]

\n

and so in this case we have:

\n

\\[ \\text{Interquartile range} = \\var{uquartile}-\\var{lquartile}=\\var{uquartile-lquartile} \\]

\n

d)

\n

Most of the data should be spanned by $4s$ where $s$ is the sample standard deviation.

\n

The range of values is $\\var{r1[31]}-\\var{r1[0]}=\\var{r1[31]-r1[0]}$ and so $s$ should be approximately

\n

\\[ \\simplify[std]{({r1[31]}-{r1[0]}) / 4 = {(r1[31] -r1[0]) / 4}} \\]

\n

The most likely value for the sample standard deviation of the options presented is $\\var{guess1}$.

\n

(The actual value is $\\var{stdev}$ to 2 decimal places).

"}, {"name": "Find sample mean, standard deviation, median and interquartile range, , ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sort(r0)", "description": "", "name": "r1"}, "things": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'tomatoes '", "description": "", "name": "things"}, "median": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.5*(r1[11]+r1[12])", "description": "", "name": "median"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "24", "description": "", "name": "n"}, "uquartile": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.25*r1[17]+0.75*r1[18]", "description": "", "name": "uquartile"}, "u": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..60)", "description": "", "name": "u"}, "whatever": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'weights'", "description": "", "name": "whatever"}, "interq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "uquartile-lquartile", "description": "", "name": "interq"}, "l": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..19)", "description": "", "name": "l"}, "var": {"templateType": "anything", "group": "Ungrouped variables", "definition": "variance(r0,true)", "description": "", "name": "var"}, "description": {"templateType": "anything", "group": "Ungrouped variables", "definition": "' from a new kind of tomato plant.'", "description": "", "name": "description"}, "lquartile": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.75*r1[5]+0.25*r1[6]", "description": "", "name": "lquartile"}, "mean": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(r0)", "description": "", "name": "mean"}, "r0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(l..u),24)", "description": "", "name": "r0"}, "units": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'grams'", "description": "", "name": "units"}, "stdev": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stdev(r0,true),2)", "description": "", "name": "stdev"}}, "ungrouped_variables": ["uquartile", "r0", "description", "things", "median", "interq", "whatever", "l", "var", "lquartile", "u", "mean", "stdev", "units", "n", "r1"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{precround(mean(r0),1)}", "minValue": "{precround(mean(r0),1)}", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{siground(stdev(r0,true),3)}", "minValue": "{siground(stdev(r0,true),3)}", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{median}", "minValue": "{median}", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{interq}", "minValue": "{interq}", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n\n\n\n\n
Sample Mean (1 dp)Sample Standard Deviation (3 sig figs)Median (exact value)Interquartile Range (exact value)
[[0]][[1]][[2]][[3]]
", "showCorrectAnswer": true, "marks": 0}], "statement": "

The following data are the {whatever}, in {units}, of $\\var{n}$ {things} {description}

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$\\var{r0[0]}$$\\var{r0[1]}$$\\var{r0[2]}$$\\var{r0[3]}$$\\var{r0[4]}$$\\var{r0[5]}$$\\var{r0[6]}$$\\var{r0[7]}$
$\\var{r0[8]}$$\\var{r0[9]}$$\\var{r0[10]}$$\\var{r0[11]}$$\\var{r0[12]}$$\\var{r0[13]}$$\\var{r0[14]}$$\\var{r0[15]}$
$\\var{r0[16]}$$\\var{r0[17]}$$\\var{r0[18]}$$\\var{r0[19]}$$\\var{r0[20]}$$\\var{r0[21]}$$\\var{r0[22]}$$\\var{r0[23]}$
", "tags": ["checked2015", "cr1", "data analysis", "elementary statistics", "interquartile range", "IQR", "lower quartile", "LQ", "MAS1604", "MAS8380", "MAS8401", "mean", "mean ", "median", "quartile", "sample mean", "sample standard deviation", "sc", "statistics", "tested1", "upper quartile", "UQ"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

11/07/2012:

\n


Added tags.

\n

Calculation not yet checked.

\n

23/07/2012:

\n

Added description.

\n

Checked calculation, OK.

\n

Two minor typos changed.

\n

3/08/2012:

\n

Added tags.

\n

Question appears to be working correctly.

\n

19/12/2012:

\n

Changed to new stats extension functions for variance and stdev. Still using the uniform distribution. Checked calculations again.

\n

Added tested1 tag.

\n

21/12/2012:

\n

Checked rounding, OK. Added cr1 tag. 

\n

Scenarios possible. Added sc tag.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Sample of size $24$ is given in a table. Find sample mean, sample standard deviation, sample median and the interquartile range.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

Sample mean: The sample mean is $\\frac{\\var{sum(r0)}}{\\var{len(r0)}} = \\var{precround(mean(r0),1)}$ to 1 decimal place.

\n

Sample standard deviation: The sample standard deviation is $\\var{stdev(r0,true)}=\\var{siground(stdev(r0,true),3)}$ to 3 significant figures.

\n

If you order the data in increasing order you get the following table:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$
$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r1[10]}$$\\var{r1[11]}$$\\var{r1[12]}$$\\var{r1[13]}$$\\var{r1[14]}$$\\var{r1[15]}$
$\\var{r1[16]}$$\\var{r1[17]}$$\\var{r1[18]}$$\\var{r1[19]}$$\\var{r1[20]}$$\\var{r1[21]}$$\\var{r1[22]}$$\\var{r1[23]}$
\n

Denote the ordered data by $x_j$, thus $x_{10}=\\var{r1[9]}$ for example.

\n

Median: The median lies between the 12th and 13th entries in the ordered table and is given by:

\n

\\[0.5\\times x_{12}+0.5\\times x_{13} = 0.5\\times\\var{r1[11]}+0.5\\times \\var{r1[12]}=\\var{median}\\]

\n

Interquartile range: As there is an even number of values, the Lower Quartile will lie between two values. Its position is calculated by finding

\n

\\[\\frac{n+1}{4}=\\frac{\\var{n+1}}{4}=6\\frac{1}{4}\\]

\n

Hence the Lower Quartile lies between the 6th and 7th entries in the ordered table.

\n

It is \\[0.75\\times x_6+0.25\\times x_7 = 0.75\\times\\var{r1[5]}+0.25\\times \\var{r1[6]}=\\var{lquartile}\\]

\n

Once again as there is an even number of values, the Upper Quartile will lie between two values and its position is calculated by finding

\n

\\[\\frac{3(n+1)}{4}=\\frac{\\var{3*(n+1)}}{4}=18\\frac{3}{4}\\]

\n

Hence the Upper Quartile lies between the 18th and 19th entries in the ordered table.

\n

We find it is \\[0.25\\times x_{18}+0.75\\times x_{19} = 0.25\\times\\var{r1[17]}+0.75\\times \\var{r1[18]}=\\var{uquartile}\\]

\n

The interquartile range is defined to be

\n

\\[ \\text{Upper Quartile} – \\text{Lower Quartile} \\]

\n

and so in this case we have:

\n

\\[ \\text{Interquartile range} = \\var{uquartile}-\\var{lquartile}=\\var{interq} \\]

"}, {"name": "Find sample standard deviations of two samples", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu,sig1)),n)", "description": "", "name": "r1"}, "mean2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(r1)", "description": "", "name": "mean2"}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(9..15)", "description": "", "name": "sig1"}, "mean1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(r0)", "description": "", "name": "mean1"}, "sig0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(6..12)", "description": "", "name": "sig0"}, "stdev1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stdev(r0,true),1)", "description": "", "name": "stdev1"}, "stdev2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stdev(r1,true),1)", "description": "", "name": "stdev2"}, "exam2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'Software Engineering'", "description": "", "name": "exam2"}, "stdevoverall": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stdev(sscores,true),1)", "description": "", "name": "stdevoverall"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "description": "", "name": "n"}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(55..65)", "description": "", "name": "mu"}, "total": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'Total Score'", "description": "", "name": "total"}, "ssq2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x^2,x,r1))", "description": "", "name": "ssq2"}, "exam1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'Programming'", "description": "", "name": "exam1"}, "var2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(variance(r1,true),3)", "description": "", "name": "var2"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "name": "m"}, "sscores": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(r0[x]+r1[x],x,0..n-1)", "description": "", "name": "sscores"}, "overallvar": {"templateType": "anything", "group": "Ungrouped variables", "definition": "variance(sscores,true)", "description": "", "name": "overallvar"}, "ssq1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x^2,x,r0))", "description": "", "name": "ssq1"}, "s": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2", "description": "", "name": "s"}, "overallmean": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(sscores)", "description": "", "name": "overallmean"}, "r0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(25..100-m),n)", "description": "", "name": "r0"}, "var1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(variance(r0,true),3)", "description": "", "name": "var1"}}, "ungrouped_variables": ["overallmean", "mean1", "mean2", "overallvar", "ssq1", "ssq2", "total", "exam2", "tol", "exam1", "stdev1", "stdev2", "var1", "var2", "sig1", "sig0", "stdevoverall", "r0", "r1", "n", "mu", "s", "sscores", "m"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{stdev1+tol}", "minValue": "{stdev1-tol}", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n \n \n

{exam1}

\n \n \n \n

Sample Standard Deviation = [[0]] (to one decimal place)

\n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{stdev2+tol}", "minValue": "{stdev2-tol}", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n \n \n

{exam2}

\n \n \n \n

Sample Standard Deviation = [[0]] (to one decimal place)

\n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{mean2+m+tol}", "minValue": "{mean2+m-tol}", "correctAnswerFraction": false, "marks": "0.5", "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "stdev2+tol", "minValue": "stdev2-tol", "correctAnswerFraction": false, "marks": "0.5", "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Suppose that each student is awarded an extra $\\var{m}$ marks  for Software Engineering. Find the new values for the sample mean and sample standard deviation.

\n

Sample mean = [[0]] (to one decimal place)

\n

Sample Standard Deviation = [[1]] (to one decimal place)

", "showCorrectAnswer": true, "marks": 0}], "statement": "

For a group of $n=10$ students, the following table gives the examination marks in Programming, $x_1,\\ldots, x_{10}$

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
{exam1}$\\var{r0[0]}$$\\var{r0[1]}$$\\var{r0[2]}$$\\var{r0[3]}$$\\var{r0[4]}$$\\var{r0[5]}$$\\var{r0[6]}$$\\var{r0[7]}$$\\var{r0[8]}$$\\var{r0[9]}$ $\\bar{x}=\\var{mean1}$
\n

For Software Engineering, their examination marks $y_1,...,y_{10}$ have been summarised as follows:

\n\n\n\n\n\n\n\n
{exam2}$\\sum y^2 = \\var{ssq2}$$\\bar{y} = \\var{mean2}$
", "tags": ["checked2015", "cr1", "data analysis", "elementary statistics", "MAS8380", "mean", "mean ", "sample", "sample mean", "sample standard deviation", "sample variance", "standard deviation", "statistics", "stats", "tested1", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

11/07/2012:

\n

Added tags.

\n

Set new variable tol=0 for all numeric input so that answers have to be accurate to 1 decimal place.

\n

Testing calculation not yet possible due to stats extension unavailability.

\n

23/07/2012:

\n

Corrected error in calculation of variance of Total Score. The variable scores was not used and so mean and variance were not correct.

\n

Checked calculations. OK.

\n

Added description.

\n

1/08/2012:

\n

Added tags.

\n

Question appears to be working correctly.

\n

19/12/2012:

\n

Changed stats functions to the ones from the new stats extension.

\n

Checked calculations.

\n

Added tested1 tag.

\n

21/12/2012:

\n

Checked rounding, OK. Added cr1 tag.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Two ordered data sets, each with 10 numbers. Find the sample standard deviation for each and for their sum.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

The solution to (a) is given below; (b) can be done in the same way.

\n

For {exam1} we have the mean is:

\n

\\[\\simplify[]{({r0[0]} + {r0[1]} + {r0[2]} + {r0[3]} + {r0[4]} + {r0[5]} + {r0[6]} + {r0[7]} + {r0[8]} + {r0[9]}) / {n} = {mean1}}\\]

\n

The sample variance is given by the formula:

\n

\\[\\textrm{Sample Variance} = \\frac{1}{n-1}\\left(\\sum_{j=1}^{n}x_j^2 -n\\bar{x}^2\\right)\\]

\n

where the $x_j$ are the exam scores for {exam1}, $n=\\var{n}$ the number of students and $\\bar{x}=\\var{mean1}$ the sample mean.

\n

We find that
\\[\\begin{eqnarray*}\\sum_{j=1}^{n}x_j^2 &=& \\simplify[]{({r0[0]}^2 + {r0[1]}^2 + {r0[2]}^2 + {r0[3]}^2 + {r0[4]}^2 + {r0[5]}^2 + {r0[6]}^2 + {r0[7]}^2 + {r0[8]}^2 + {r0[9]}^2)}\\\\ &=& \\var{ssq1}\\\\ \\\\ \\\\ n\\bar{x}^2 &=&\\var{n} \\times\\var{mean1}^2\\\\ &=& \\var{n*mean1^2} \\end{eqnarray*} \\]
Hence substituting these values into the formula we find that:

\n

\\[\\begin{eqnarray*} \\textrm{Sample Variance} &=& \\frac{1}{\\var{n-1}}\\left(\\var{ssq1}-\\var{n*mean1^2}\\right)\\\\ &=& \\var{var1} \\end{eqnarray*} \\] to 3 decimal places.

\n

The Sample Standard Deviation is then the square root of the Sample Variance i.e.

\n

Sample Standard Deviation = $\\sqrt{\\var{var1}} = \\var{stdev1}$ to one decimal place.

\n

In part (c), adding a constant, $\\var{m}$, to each score shifts the mean by the same constant. The spread of the data is unaffected and so the sample standard deviation remains unchanged.

"}, {"name": "Calculate probability of combinations of events happening or not, , ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{intersect-tol}", "maxValue": "{intersect+tol}", "marks": 1}], "type": "gapfill", "prompt": "\n \n \n

$P(A\\cap B)=\\;\\;$[[0]]

\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{intcom-tol}", "maxValue": "{intcom+tol}", "marks": 1}], "type": "gapfill", "prompt": "\n \n \n

$P(A^c\\cap B^c)=\\;\\;$[[0]]

\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{unioncom-tol}", "maxValue": "{unioncom+tol}", "marks": 1}], "type": "gapfill", "prompt": "\n \n \n

$P(A^c\\cup B^c)=\\;\\;$[[0]]

\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{prob4-tol}", "maxValue": "{prob4+tol}", "marks": 1}], "type": "gapfill", "prompt": "\n \n \n

$P(A^c\\cap B)=\\;\\;$[[0]]

\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{prob5-tol}", "maxValue": "{prob5+tol}", "marks": 1}], "type": "gapfill", "prompt": "\n \n \n

$P(A^c\\cup B)=\\;\\;$[[0]]

\n \n \n ", "showCorrectAnswer": true, "marks": 0}], "variables": {"prob4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-prob2-intersect,10)", "name": "prob4", "description": ""}, "intcom": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-prob3", "name": "intcom", "description": ""}, "intersect": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(prob1+1-prob2-prob3,2)", "name": "intersect", "description": "

P(A and B)

"}, "prob2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.1..0.9#0.05)", "name": "prob2", "description": "

P(not B)

"}, "prob3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((t*(max(prob1,1-prob2))+(100-t)*min(0.95,prob1+1-prob2))/100,2)", "name": "prob3", "description": "

P(A or B)

"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0", "name": "tol", "description": ""}, "unioncom": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-intersect", "name": "unioncom", "description": ""}, "prob1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.1..0.9#0.05)", "name": "prob1", "description": "

P(A)

"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..100)", "name": "t", "description": ""}, "prob5": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-prob1+1-prob2-prob4", "name": "prob5", "description": ""}}, "ungrouped_variables": ["intcom", "intersect", "prob1", "prob2", "prob3", "prob4", "prob5", "t", "tol", "unioncom"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "showQuestionGroupNames": false, "variable_groups": [], "functions": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "\n

Let $A$ and $B$ be events with:

\n

1. $P(A) = \\var{prob1}$

\n

2. $P(A \\cup B)=\\var{prob3}$

\n

3. $P(B^c)=\\var{prob2}$

\n

Find the following probabilities (all answers to 2 decimal places):

\n ", "tags": ["axiom", "axioms of probability", "checked2015", "complement", "complement of an event", "cr1", "elementary probability", "intersection of events", "intersection of sets", "laws of sets", "MAS1604", "MAS8380", "MAS8401", "Probability", "probability", "probability laws", "set laws", "sets", "statistics", "tested1", "union", "union of events", "union of sets"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

7/07/2012:

\n

Added tags.

\n

Set tolerances via new variable tol=0 for all answers.

\n

Checked calculations.

\n

22/07/2012:

\n

Added description.

\n

Switched on stats extension (not needed, but policy for all stats questions).

\n

31/07/2012:

\n

Added tags.

\n

In the Advice section, moved \\Rightarrow to beginning of the line instead of the end of the previous line.

\n

Question appears to be working correctly.

\n

20/12/2012:

\n

Added tested1 tag after checking again - calculations OK.

\n

21/12/2012:

\n

Checked rounding, OK. Added tag cr1.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Given  $P(A)$, $P(A\\cup B)$, $P(B^c)$ find $P(A \\cap B)$, $P(A^c \\cap B^c)$, $P(A^c \\cup B^c)$ etc..

"}, "advice": "

a)

\n

It follows from the axioms of probability that:

\n

\\[P(A \\cup B)=P(A)+P(B)-P(A \\cap B)\\]

\n

Hence

\n

\\begin{align}
P(A \\cap B) &= P(A)+P(B)-P(A \\cup B) \\\\
&= \\var{prob1}+1-\\var{prob2}-\\var{prob3} \\\\
&= \\var{intersect}
\\end{align}

\n

Note that we have used $P(B)=1-P(B^c)= 1-\\var{prob2}=\\var{1-prob2}$

\n

b)

\n

The laws of sets gives:

\n

\\[A^c \\cap B^c=(A \\cup B)^c\\]

\n

so

\n

\\begin{align}
P(A^c \\cap B^c) &= P((A \\cup B)^c) \\\\
&= 1-P(A \\cup B) \\\\
&= 1-\\var{prob3} \\\\
&= \\var{1-prob3}
\\end{align}

\n

c)

\n

Similarly to b), the laws of sets gives:

\n

\\[A^c \\cup B^c=(A \\cap B)^c\\]

\n

so

\n

\\begin{align}
P(A^c \\cup B^c) &= P((A \\cap B)^c) \\\\
&= 1-P(A \\cap B) \\\\
&= 1-\\var{intersect} \\\\
&= \\var{1-intersect}
\\end{align}

\n

d)

\n

Note that $B$ is the following union of disjoint sets:

\n

\\[B = (A^c \\cap B) \\cup (A \\cap B)\\]

\n

Hence

\n

\\begin{align}
P(B) &= P(A^c \\cap B) + P(A \\cap B) \\\\
\\implies P(A^c \\cap B) &= P(B)-P(A\\cap B) \\\\
&= 1-\\var{prob2}-\\var{intersect} \\\\
&= \\var{prob4}
\\end{align}

\n

e)

\n

Once again using a familiar result we have:

\n

\\begin{align}
P(A^c \\cup B) &= P(A^c)+P(B)-P(A^c \\cap B) \\\\
&= 1-\\var{prob1}+1-\\var{prob2}-\\var{prob4} \\\\
&= \\var{prob5}
\\end{align}

\n

Where we used the result from d) that $P(A^c \\cap B)=\\var{prob4}$

"}, {"name": "Calculate probability of either of two events occurring", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variablesTest": {"condition": "", "maxRuns": 100}, "variables": {"dothisandthat": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"work on both domestic and European routes\"", "description": "", "name": "dothisandthat"}, "ans2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-prob1,2)", "description": "", "name": "ans2"}, "desc2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"are in training\"", "description": "", "name": "desc2"}, "things": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'stewardesses'", "description": "", "name": "things"}, "dothat1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"works on European routes\"", "description": "", "name": "dothat1"}, "p3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "p-random(85..95)", "description": "", "name": "p3"}, "prob1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((p-p3)/100,2)", "description": "", "name": "prob1"}, "therest": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"The remainder\"", "description": "", "name": "therest"}, "desc1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"with a small UK-based airline\"", "description": "", "name": "desc1"}, "p2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "p-p1", "description": "", "name": "p2"}, "thing": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"stewardess\"", "description": "", "name": "thing"}, "dothis1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"works on domestic routes\"", "description": "", "name": "dothis1"}, "desc4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"is in training\"", "description": "", "name": "desc4"}, "dothat": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"work on European routes\"", "description": "", "name": "dothat"}, "dothis": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"work on domestic routes\"", "description": "", "name": "dothis"}, "p1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(40..70)", "description": "", "name": "p1"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(105..125)", "description": "", "name": "p"}, "desc3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"working with this airline\"", "description": "", "name": "desc3"}}, "ungrouped_variables": ["dothisandthat", "desc4", "p1", "desc1", "dothat", "desc3", "things", "ans2", "p3", "p", "p2", "dothat1", "dothis", "therest", "desc2", "thing", "dothis1", "prob1"], "functions": {}, "variable_groups": [], "preamble": {"css": "", "js": ""}, "parts": [{"customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "prompt": "\n

Find the probabilities that a randomly chosen {thing} {desc3}: 

\n

a) {dothis1} or {dothat1}.

\n

Probability = [[0]]

\n

b) {desc4}.

\n

Probability = [[1]]

\n

Enter both probabilities to 2 decimal places.

\n ", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "minValue": "prob1", "maxValue": "prob1", "unitTests": [], "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "scripts": {}, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "variableReplacements": [], "marks": 1, "mustBeReducedPC": 0}, {"correctAnswerFraction": false, "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "minValue": "ans2", "maxValue": "ans2", "unitTests": [], "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "scripts": {}, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "variableReplacements": [], "marks": 1, "mustBeReducedPC": 0}], "type": "gapfill", "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}], "statement": "\n

$\\var{p1}$% of {things} {desc1} {dothis}, $\\var{p2}$% {dothat} and $\\var{p3}$% {dothisandthat}. 

\n

{therest} {desc2}

\n ", "tags": ["checked2015"], "rulesets": {}, "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Example showing how to calculate the probability of A or B using the law $p(A \\;\\textrm{or}\\; B)=p(A)+p(B)-p(A\\;\\textrm{and}\\;B)$. 

\n

Also converting percentages to probabilities.

\n

Easily adapted to other applications.

"}, "advice": "

a) There are $\\var{p1}+\\var{p2}-\\var{p3}=\\var{p-p3}$ % of stewardesses working on one of the routes. The probability that a random stewardess is working on one of these routes is therefore $\\displaystyle \\frac{\\var{p-p3}}{100}=\\var{prob1}$.

\n

b) The rest are in training and the probability that a randomly selected stewardess is in training is $1-\\var{prob1}=\\var{1-prob1}$.

"}, {"name": "Convert gambling odds to probabilities, , ", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"wdw": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'A bookmaker lists'", "description": "", "name": "wdw"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0..20)", "description": "", "name": "t"}, "player1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'Australia'", "description": "", "name": "player1"}, "odds22": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round(odds12*odds21/odds11)-random(2..5 except round(odds12*odds21/odds11))", "description": "", "name": "odds22"}, "den2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "odds21+odds22", "description": "", "name": "den2"}, "odds21": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(8..20)", "description": "", "name": "odds21"}, "between": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'between'", "description": "", "name": "between"}, "odds12": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round((t*round(odds11+1)/2+(20-t)*(odds11-1))/20)", "description": "", "name": "odds12"}, "odds11": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(8..20)", "description": "", "name": "odds11"}, "event": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'the next series of games'", "description": "", "name": "event"}, "player2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'England'", "description": "", "name": "player2"}, "den1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "odds11+odds12", "description": "", "name": "den1"}}, "ungrouped_variables": ["odds12", "odds11", "den2", "den1", "wdw", "player2", "player1", "t", "between", "odds22", "event", "odds21"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"answer": "{odds11}/{den1}", "musthave": {"message": "

Input as a fraction.

", "showStrings": false, "partialCredit": 0, "strings": ["/"]}, "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showCorrectAnswer": true, "expectedvariablenames": [], "notallowed": {"message": "

Input your answer as a fraction and not a decimal.

", "showStrings": false, "partialCredit": 0, "strings": ["."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "answersimplification": "std, fractionNumbers", "marks": 1, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "

You should take the bet if you think that $\\Pr(\\var{player1}\\text{ win})$ is greater than [[0]]

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"answer": "{odds22}/{den2}", "musthave": {"message": "

Input as a fraction.

", "showStrings": false, "partialCredit": 0, "strings": ["/"]}, "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showCorrectAnswer": true, "expectedvariablenames": [], "notallowed": {"message": "

Input your answer as a fraction and not a decimal.

", "showStrings": false, "partialCredit": 0, "strings": ["."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "answersimplification": "std, fractionNumbers", "marks": 1, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "

You should take the bet if you think that $\\Pr(\\var{player2}\\text{ win})$ is greater than [[0]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

The following odds are given for {event} {between} {player1} and {player2}

\n\n\n\n\n\n\n\n
{player1} $\\var{odds11}: \\var{odds12}$ on{player2} $\\var{odds21}: \\var{odds22}$ against
\n

Convert these statements about odds into probabilities.

\n

Give your answers as fractions.

", "tags": ["checked2015", "converting odds", "elementary probability", "MAS1604", "MAS8380", "MAS8401", "odds", "odds into probabilities", "probability", "Probability", "statistics", "tested1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

7/07/2012:

\n

Added tags.

\n

Added decimal point as forbidden string for both answers.

\n

Checked calculation.

\n

22/07/2012:

\n

Added description.

\n

31/07/2012:

\n

Added tags.

\n

Question appears to be working correctly.

\n

20/12/2012:

\n

Checked calculations, OK. Added tested1 tag.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Converting odds to probabilities.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

a)

\n

Odds of $\\var{odds11}: \\var{odds12}$ on means that you should take the bet if you think the probability of {player1} winning is greater than:

\n

\\[ \\frac{\\var{odds11}}{\\var{odds11}+\\var{odds12}} = \\simplify[std]{{odds11}/{odds11+odds12}}\\]

\n

b)

\n

Odds of $\\var{odds21}: \\var{odds22}$ against means that you should take the bet if you think that the probability of {player2} losing is less than:

\n

\\[ \\frac{\\var{odds21}}{\\var{odds21}+\\var{odds22}} = \\simplify[std]{{odds21}/{odds21+odds22}}\\]

\n

That is, if you think the probability of {player2} winning is greater than:

\n

\\[ 1- \\simplify[std]{{odds21}/{odds21+odds22}}=\\simplify[std]{{odds22}/{odds21+odds22}}\\]

\n

Note that the sum of these probabilities is:

\n

\\[\\simplify[std]{{odds11}/{odds11+odds12}}+\\simplify[std]{{odds22}/{odds21+odds22}}=\\simplify[std]{{odds11*odds21+odds22*odds12+2*odds11*odds22}/{odds11*odds21+odds22*odds12+odds11*odds22+odds12*odds21}}\\]

\n

which is less than $1$, as otherwise you could bet on both to win and not lose any money!

"}, {"name": "Probability - sum of two numbers drawn without replacement", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"noeven": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(isint(mi/2),di/2+1,di/2)", "description": "", "name": "noeven"}, "botheven": {"templateType": "anything", "group": "Ungrouped variables", "definition": "comb(noeven,2)", "description": "", "name": "botheven"}, "together": {"templateType": "anything", "group": "Ungrouped variables", "definition": "botheven+bothodd", "description": "", "name": "together"}, "numpar": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(parity='even',noeven,noodd)", "description": "", "name": "numpar"}, "mess": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(gcd(comb(numpar,2),together)=1,'','(after reducing to lowest form as a fraction).')", "description": "", "name": "mess"}, "mi": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..10)", "description": "", "name": "mi"}, "otherparity": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(parity='even','odd','even')", "description": "", "name": "otherparity"}, "bothodd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "comb(noodd,2)", "description": "", "name": "bothodd"}, "ma": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mi+random(8..12#2)", "description": "", "name": "ma"}, "di": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ma-mi", "description": "", "name": "di"}, "parity": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random('odd','even')", "description": "", "name": "parity"}, "noodd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(isint(mi/2),di/2,di/2+1)", "description": "", "name": "noodd"}, "numotherpar": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(parity='even',noodd,noeven)", "description": "", "name": "numotherpar"}, "bothsame": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(parity='odd',bothodd,botheven)", "description": "", "name": "bothsame"}}, "ungrouped_variables": ["parity", "otherparity", "ma", "di", "mess", "mi", "numotherpar", "noodd", "together", "bothodd", "botheven", "numpar", "bothsame", "noeven"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"answer": "{bothsame}/{botheven+bothodd}", "musthave": {"showStrings": false, "message": "

Input your answer as a fraction

", "strings": ["/"], "partialCredit": 0}, "vsetrange": [0, 1], "checkingaccuracy": 0.001, "answersimplification": "std", "expectedvariablenames": [], "notallowed": {"showStrings": false, "message": "

Input your answer as a fraction not a decimal.

", "strings": ["."], "partialCredit": 0}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "showCorrectAnswer": true, "marks": 2, "vsetrangepoints": 5}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "\n

Probability that both numbers are {parity}= [[0]]

\n

Enter your answer as a fraction and not a decimal.

\n ", "marks": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "\n

Two numbers are drawn at random (and without replacement) from the numbers $\\var{mi}$ to $\\var{ma}$.

\n

Find the probability that both numbers are {parity} given that their sum is even.

\n ", "tags": ["MAS1604", "Probability", "checked2015", "conditional probability", "counting", "drawn without replacement", "events", "sampling space", "select without replacement", "sets", "statistics", "subset", "tested1", "urn model", "without replacement"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

7/07/2012:

\n

Added tags.

\n

Reminded user to input answer as a fraction.

\n

Checked calculation.

\n

 22/07/2012:

\n

Added description.

\n

Checked stats extension box.

\n

31/07/2012:

\n

Question appears to be working correctly.

\n

20/12/2012:

\n

Checked calculation, OK. Added tested1 tag.

", "licence": "Creative Commons Attribution 4.0 International", "description": "\n \t\t

Two numbers are drawn at random without replacement from the numbers m to n.

\n \t\t

Find the probability that both are odd given their sum is even.

\n \t\t"}, "advice": "\n \n \n

As we are sampling without replacement the best sampling space is the space of all unordered pairs.

\n \n \n \n

This means that when we count up the number of pairs we use the number of ways of selecting pairs.

\n \n \n \n

Let $A$ be the event that both numbers are {parity} and $B$ the event that their sum is even.

\n \n \n \n

Note that $A$ is a subset of $B$ hence $P(A \\cap B)=P(A)$.

\n \n \n \n

The probability we want to find is $P(A | B)$.

\n \n \n \n

Using the definition of conditional probability:

\n \n \n \n

\\[P(A | B) = \\frac{P(A \\cap B)}{P(B)} = \\frac{P(A)}{P(B)} \\]

\n \n \n \n

Now there are $\\var{numpar}$ {parity} numbers between $\\var{mi}$ and $\\var{ma}$.

\n \n \n \n

and as we are sampling without replacement there are

\n \n \n \n

\\[{\\var{numpar} \\choose 2} = \\frac{\\var{numpar}\\times \\var{numpar-1}}{2} = \\var{comb(numpar,2)}\\]

\n \n \n \n

such pairs, both {parity}.

\n \n \n \n

This gives the number of elements in $A$.

\n \n \n \n

Also since there are $\\var{ma-mi+1-numpar}$ {otherparity} numbers in the range, there are:

\n \n \n \n

\\[{\\var{numotherpar} \\choose 2}=\\var{comb(numotherpar,2)}\\] such pairs, both {otherparity}.

\n \n \n \n

There are $\\var{botheven}+\\var{bothodd}=\\var{together}$ pairs with sum even.

\n \n \n \n

This gives the number of events in $B$.

\n \n \n \n

Hence \\[\\frac{P(A)}{P(B)}=\\frac{\\var{comb(numpar,2)}}{\\var{together}}\\]

\n \n \n \n

So the probability that both are {parity} given their sum is even is

\n \n \n \n

\\[\\simplify[std]{{comb(numpar,2)}/{together}}\\]

\n \n \n \n

{mess}

\n \n \n "}, {"name": "Roll a pair of dice - find probability at least one die shows a given number.", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "tags": ["checked2015", "dice", "Dice", "die", "elementary probability", "events", "independence", "Independence", "independent events", "Probability", "probability", "probability dice", "statistics", "tested1"], "metadata": {"description": "

Rolling a pair of dice. Find probability that at least one die shows a given number.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

Two fair six-sided dice are rolled.

", "advice": "\n \n \n

Let $A$ be the event that first dice shows a $\\var{number}$ $\\Rightarrow P(A)=\\frac{1}{6}$.

\n \n \n \n

Let $B$ be the event that second dice shows a $\\var{number}$ $\\Rightarrow P(B)=\\frac{1}{6}$.

\n \n \n \n

$A$ and $B$ are independent events so $P(A\\cap B) = P(A)\\times P(B)$.

\n \n \n \n

We want the probability $P(A \\cup B)$ of either $A$ or $B$ showing $\\var{number}$ and

\n \n \n \n

\\[\\begin{eqnarray*}\n \n P(A \\cup B) &=& P(A)+P(B)-P(A \\cap B)\\\\\n \n &=& P(A)+P(B)-P(A)P(B)\\\\\n \n &=&\\frac{1}{6}+ \\frac{1}{6}-\\frac{1}{36}\\\\\n \n &=& \\frac{11}{36}\n \n \\end{eqnarray*}\n \n \\]

\n \n \n ", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"number": {"name": "number", "group": "Ungrouped variables", "definition": "random(1..6)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["number"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

What is the probability of at least one die showing a $\\var{number}$?

\n

Probability = [[0]]

", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "11/36", "maxValue": "11/36", "correctAnswerFraction": true, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Calculate expectation and a probability from a frequency table, , , ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [{"variables": ["idef", "thing", "episodes", "period", "activity"], "name": "Strings"}, {"variables": ["p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8", "probabilities", "values"], "name": "Probabilities"}, {"variables": ["r", "s", "t", "t1", "t2", "u1", "u2", "u3", "d"], "name": "Stuff to generate probabilities"}], "variables": {"p4": {"templateType": "anything", "group": "Probabilities", "definition": "t-p8-p7-p6-p5", "description": "", "name": "p4"}, "expected_number": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x*y,[x,y],zip(probabilities,values)))", "description": "", "name": "expected_number"}, "u2": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "u1", "description": "", "name": "u2"}, "p1": {"templateType": "anything", "group": "Probabilities", "definition": "p0+t1", "description": "", "name": "p1"}, "p3": {"templateType": "anything", "group": "Probabilities", "definition": "r-p0-p1-p2", "description": "", "name": "p3"}, "t": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "100-r", "description": "", "name": "t"}, "probexceed": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(if(j>expected_number,probabilities[j],0),j,0..8))", "description": "", "name": "probexceed"}, "values": {"templateType": "anything", "group": "Probabilities", "definition": "list(0..8)", "description": "", "name": "values"}, "thing": {"templateType": "string", "group": "Strings", "definition": "\"airline\"", "description": "", "name": "thing"}, "u3": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "u1", "description": "", "name": "u3"}, "u1": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "round(d*random(70..100)/100)", "description": "", "name": "u1"}, "expect_int": {"templateType": "anything", "group": "Ungrouped variables", "definition": "floor(expected_number)", "description": "", "name": "expect_int"}, "activity": {"templateType": "string", "group": "Strings", "definition": "\"luggage handling\"", "description": "", "name": "activity"}, "probabilities": {"templateType": "anything", "group": "Probabilities", "definition": "map(x/100,x,[p0,p1,p2,p3,p4,p5,p6,p7,p8])", "description": "

Probability of there being $i$ episodes

", "name": "probabilities"}, "d": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "round(t/15)", "description": "", "name": "d"}, "episodes": {"templateType": "string", "group": "Strings", "definition": "\"complaints\"", "description": "", "name": "episodes"}, "t2": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "t1", "description": "", "name": "t2"}, "p8": {"templateType": "anything", "group": "Probabilities", "definition": "d", "description": "", "name": "p8"}, "p7": {"templateType": "anything", "group": "Probabilities", "definition": "p8+u1", "description": "", "name": "p7"}, "p5": {"templateType": "anything", "group": "Probabilities", "definition": "p6+u3", "description": "", "name": "p5"}, "idef": {"templateType": "string", "group": "Strings", "definition": "\"an\"", "description": "", "name": "idef"}, "p2": {"templateType": "anything", "group": "Probabilities", "definition": "p1+t2", "description": "", "name": "p2"}, "t1": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "round(s*random(70..100)/100)", "description": "", "name": "t1"}, "r": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "random(45..65)", "description": "", "name": "r"}, "s": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "round(r/10)", "description": "", "name": "s"}, "p0": {"templateType": "anything", "group": "Probabilities", "definition": "s", "description": "", "name": "p0"}, "p6": {"templateType": "anything", "group": "Probabilities", "definition": "p7+u2", "description": "", "name": "p6"}, "period": {"templateType": "string", "group": "Strings", "definition": "\"day\"", "description": "", "name": "period"}}, "ungrouped_variables": ["expected_number", "expect_int", "probexceed"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "expected_number", "maxValue": "expected_number", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 2}], "type": "gapfill", "prompt": "

Find the expected number of {episodes} per {period}.

\n

Expected number = [[0]]

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "probexceed", "maxValue": "probexceed", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 2}], "type": "gapfill", "prompt": "

What is the probability that the number of {episodes} will exceed the expected number?

\n

Probability = [[0]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

The probabilities that {idef} {thing} will receive {episodes} per {period} about its {activity} are given by the following table:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Complaints{values[0]}{values[1]}{values[2]}{values[3]}{values[4]}{values[5]}{values[6]}{values[7]}{values[8]}
Probability{probabilities[0]}{probabilities[1]}{probabilities[2]}{probabilities[3]}{probabilities[4]}{probabilities[5]}{probabilities[6]}{probabilities[7]}{probabilities[8]}
\n

Answer the following two parts, giving your answers to $2$ decimal places.

", "tags": ["checked2015", "discrete distribution", "expectation", "expected value", "MAS1604", "MAS2304", "MAS8380", "MAS8401", "mass function", "pmf", "PMF", "Probability", "probability", "probability mass function", "query", "sc", "statistics", "tested1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

7/07/2012:

\n

Added tags.

\n

Checked calculation.

\n

22/07/2012:

\n

Added description.

\n

Ticked stats extension box.

\n

31/07/2012:

\n

Added tags.

\n

Question appears to be working correctly.

\n

20/12/2012:

\n

Could increase the number of scenarios by using random string variables. Query tag added for that.

\n

Also very cumbersome use of variables. But no change proposed for now.

\n

Checked calculation, OK. Added tested1 tag.

\n

21/12/2012:

\n

Although asks for solution to 2 dps, there is no rounding as the raw values are to 2 dps. Added sc tag for possible scenarios.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Given a probability mass function $P(X=i)$ with outcomes $i \\in \\{0,1,2,\\ldots 8\\}$, find the expectation $E$ and $P(X \\gt E)$.

"}, "variablesTest": {"condition": "", "maxRuns": "100"}, "advice": "

a)

\n

The expected number of {episodes} is given by:

\n

\\[ \\simplify[]{{probabilities[0]}*{values[0]} + {probabilities[1]}*{values[1]} + {probabilities[2]}*{values[2]} + {probabilities[3]}*{values[3]} + {probabilities[4]}*{values[4]} + {probabilities[5]}*{values[5]} + {probabilities[6]}*{values[6]} + {probabilities[7]}*{values[7]} + {probabilities[8]}*{values[8]}} = \\var{expected_number} \\]

\n

b)

\n

We want the probability that the number of {episodes} exceeds $\\var{expected_number}$.

\n

Since the number of {episodes} is a whole number, this is the same as the probability that the number is $\\var{expect_int+1}$ or more and is

\n

\\[\\sum_{i=\\var{expect_int+1}}^{i=8} \\left( \\text{Probability}(\\var{episodes} = i ) \\right)= \\simplify[zeroTerm]{ {if(expect_int<1,probabilities[1],0)} + {if(expect_int<2,probabilities[2],0)} + {if(expect_int<3,probabilities[3],0)} + {if(expect_int<4,probabilities[4],0)} + {if(expect_int<5,probabilities[5],0)} + {if(expect_int<6,probabilities[6],0)} + {if(expect_int<7,probabilities[7],0)} + {if(expect_int<8,probabilities[8],0)}} = \\var{probexceed}\\]

"}, {"name": "Find expected profit of gambles, ", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"profit": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(numberbets*bet-numberbets*bet*(odds1+odds2)/(odds2*number),2)", "description": "", "name": "profit"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..6)", "description": "", "name": "r"}, "number": {"templateType": "anything", "group": "Ungrouped variables", "definition": "37", "description": "", "name": "number"}, "odds2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1", "description": "", "name": "odds2"}, "bet": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1,10,50,100)", "description": "", "name": "bet"}, "odds1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "35", "description": "", "name": "odds1"}, "numberbets": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10^r", "description": "", "name": "numberbets"}}, "ungrouped_variables": ["profit", "numberbets", "number", "r", "bet", "odds2", "odds1"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "profit", "minValue": "profit", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n

Expected profit=£[[0]]

\n

Enter to two decimal places.

\n

\n ", "showCorrectAnswer": true, "marks": 0}], "statement": "

A roulette table has $\\var{number}$ numbers and pays at $\\var{odds1}$ to $\\var{odds2}$ if the winning number is chosen.

\n

Find the expected profit to the casino if $\\var{10^{r}}$ bets of £$\\var{bet}$ are placed independently.

", "tags": ["checked2015", "MAS8380", "MAS8401"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

04/11/2013

\n

Fix typo \"fod\" -> \"find\".

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Given a large number of gambles, find the expected profit.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "\n

The probability of winning is $\\dfrac{1}{\\var{number}}$ and the odds of $\\var{odds1}$ to $\\var{odds2}$ tells us that each winning choice realises \\[\\text{£}\\simplify{{odds1+odds2}/{odds2}}\\times \\var{bet}=\\text{£}\\var{(odds1+odds2)*bet/odds2}\\]on a bet of £ $\\var{bet}$. 

\n

Hence the expected payout on a bet of £$\\var{bet}$ is £$\\frac{\\var{(odds1+odds2)*bet}}{\\var{odds2*number}}$

\n

So the expected payout on $\\var{numberbets}$ bets of £$\\var{bet}$ is $\\var{numberbets}\\times \\frac{\\var{(odds1+odds2)*bet}}{\\var{odds2*number}}$

\n

Hence:

\n

Profit = Income - Payout

\n

$=\\text{£}\\var{numberbets}\\times \\var{bet}-\\var{numberbets}\\times \\frac{\\var{(odds1+odds2)*bet}}{\\var{odds2*number}}= \\text{£}\\var{profit}$ to 2 decimal places.

\n

\n "}, {"name": "Tom 1341cba2b extra", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"p2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.1..p1-0.1)", "name": "p2", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "name": "tol", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(7..12)", "name": "n", "description": ""}, "p1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.5..0.8)", "name": "p1", "description": ""}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..5)", "name": "m", "description": ""}, "q": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.05..0.2)", "name": "q", "description": ""}, "pcont": {"templateType": "anything", "group": "Ungrouped variables", "definition": "binomialpdf(m,n,p2)*q/psurvive", "name": "pcont", "description": ""}, "psurvive": {"templateType": "anything", "group": "Ungrouped variables", "definition": "binomialpdf(m,n,p1)*(1-q)+ binomialpdf(m,n,p2)*q", "name": "psurvive", "description": ""}, "anspcont": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pcont,3)", "name": "anspcont", "description": ""}, "anspsurvive": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(psurvive,3)", "name": "anspsurvive", "description": ""}}, "ungrouped_variables": ["p2", "p1", "psurvive", "m", "n", "q", "pcont", "tol", "anspsurvive", "anspcont"], "rulesets": {}, "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"displayType": "radiogroup", "choices": ["

Binomial

", "

Geometric

", "

Poisson

", "

Other

"], "matrix": [1, 0, 0, 0], "distractors": ["", "", "", ""], "shuffleChoices": true, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "displayColumns": 0, "marks": 0}], "type": "gapfill", "prompt": "

Which probability distribution is best suited to represent the number of cells that die (assuming you know whether or not the equipment is contaminated)?[[0]]

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"showCorrectAnswer": true, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "anspsurvive-tol", "prompt": "

If it's not known whether the equipment is contaminated, what is the probability that $\\var{m}$ cultures survive longer than a week?

\n

Probability = ? (to 3 decimal places).

", "marks": 1, "maxValue": "anspsurvive+tol"}, {"showCorrectAnswer": true, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "anspcont-tol", "prompt": "

Given that $\\var{m}$ cultures survive longer than a week, what is the probability that the equipment was contaminated? (Use the value to at least 5 decimal places from part b) rather than the value to 3 decimal places).

\n

Probability=? (to 3 decimal places).

", "marks": 1, "maxValue": "anspcont+tol"}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

In a laboratory experiment $\\var{n}$ yeast cultures are grown and the number that are still alive after one week is counted. Each culture independently survives longer than a week with probability $p = \\var{p1}$. However, there is a probability $\\var{q}$ that the laboratory equipment is contaminated. If that is the case, then all the cultures are affected, and the probability of survival after one week drops to $p = \\var{p2}$.

\n

 

", "tags": ["checked2015", "junk"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": ""}, "advice": "

a) The binomial distribution.

\n

b) Using the law of total probability:

\n

\\[\\begin{eqnarray*}\\operatorname{Pr}(\\var{m}\\;\\text{ survive})&=&\\operatorname{Pr}(\\var{m}\\; \\text{survive|uncontaminated})\\operatorname{Pr}(\\text{uncontaminated})+\\operatorname{Pr}(\\var{m} \\;\\text{survive|contaminated})\\operatorname{Pr}(\\text{contaminated})\\\\&=&{\\var{n} \\choose\\var{m}}\\var{p1}^{\\var{m}}(1-\\var{p1})^{\\var{n-m}} \\times (1-\\var{q})+{\\var{n} \\choose\\var{m}}\\var{p2}^{\\var{m}}(1-\\var{p2})^{\\var{n-m}} \\times \\var{q}\\\\&=&\\var{psurvive}\\\\&=&\\var{anspsurvive}\\end{eqnarray*}\\] to 3 decimal places.

\n

c) By Baye's theorem:

\n

\\[\\begin{eqnarray*}\\operatorname{Pr}\\text{contaminated|}\\var{m}\\;\\text{survive})&=&\\frac{\\operatorname{Pr}(\\var{m} \\;\\text{survive|contaminated})\\operatorname{Pr}(\\text{contaminated})}{\\operatorname{Pr}(\\var{m}\\;\\text{ survive})}\\\\&=&\\frac{{\\var{n} \\choose\\var{m}}\\var{p2}^{\\var{m}}(1-\\var{p2})^{\\var{n-m}} \\times \\var{q}}{\\var{psurvive}}\\\\&=&\\var{anspcont}\\end{eqnarray*}\\] to 3 decimal places.

\n

 

"}, {"name": "Calculate probabilities from a normal distribution, ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.0001", "description": "", "name": "tol"}, "amount": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"electricity consumption\"", "description": "", "name": "amount"}, "p1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "normalcdf((upper-m)/s,0,1)", "description": "", "name": "p1"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(750..1250#50)", "description": "", "name": "m"}, "prob1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(normalcdf(lower,m,s),4)", "description": "", "name": "prob1"}, "stuff": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"a frozen foods warehouse each week in the summer months \"", "description": "", "name": "stuff"}, "lower": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(m-1.5*s..m-0.5s#5)", "description": "", "name": "lower"}, "prob2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-normalcdf(upper,m,s),4)", "description": "", "name": "prob2"}, "s": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(60..100#10)", "description": "", "name": "s"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "normalcdf((m-lower)/s,0,1)", "description": "", "name": "p"}, "upper": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(m+0.5s..m+1.5*s#5)", "description": "", "name": "upper"}, "units1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"k Wh\"", "description": "", "name": "units1"}}, "ungrouped_variables": ["units1", "upper", "lower", "p1", "m", "s", "p", "amount", "stuff", "tol", "prob2", "prob1"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "prob1+tol", "minValue": "prob1-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "prob2+tol", "minValue": "prob2-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Find the probability that in a particular week the {amount} is less than {lower} {units1}:

\n

Probability = [[0]](to 4  decimal places)

\n

Find the probability that in a particular week the {amount} is greater than {upper} {units1}:

\n

Probability = [[1]](to 4  decimal places)

", "showCorrectAnswer": true, "marks": 0}], "statement": "

The {amount}, $X$, of {stuff}  is normally distributed with mean {m}{units1} and standard deviation {s}{units1}.

\n

i.e.   \\[X \\sim \\operatorname{N}(\\var{m},\\var{s}^2)\\]

\n

 

", "tags": ["checked2015", "continuous random variable", "MAS8380", "MAS8401", "mean", "mean ", "Normal distribution", "normal distribution", "normal tables", "probabilities", "random variable", "sc", "standard deviation", "statistical distributions", "statistics", "z-scores"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

1/1/2012:

\n \t\t \t\t

Can be configured to other applications using the string variables suppplied. Included tag sc.

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Given a random variable $X$  normally distributed as $\\operatorname{N}(m,\\sigma^2)$ find probabilities $P(X \\gt a),\\; a \\gt m;\\;\\;P(X \\lt b),\\;b \\lt m$.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

1. Converting to $\\operatorname{N}(0,1)$

\n

$\\simplify[all,!collectNumbers]{P(X < {lower}) = P(Z < ({lower} -{m}) / {s}) = P(Z < {lower-m}/{s}) = 1 -P(Z < {m-lower}/{s})} = 1 -\\var{p} = \\var{precround(1 -p,4)}$ to 4 decimal places.

\n

Here the probability could have been looked up from normal CDF tables. Alternatively we can simply do the whole

\n

calculation in R by typing $\\operatorname{pnorm}(\\var{lower},\\var{m},\\var{s})$.

\n

2. Converting to $\\operatorname{N}(0,1)$

\n

$\\simplify[all,!collectNumbers]{P(X > {upper}) = P(Z > ({upper} -{m}) / {s}) = P(Z > {upper-m}/{s}) = 1 -P(Z < {upper-m}/{s})} = 1-\\var{p1} = \\var{precround(1 -p1,4)}$ to 4 decimal places.

\n

Here the probability could have been looked up from normal CDF tables. Alternatively we can

\n

simply do the whole calculation in R by typing 1 - pnorm({upper},{m},{s}).

"}, {"name": "Construct a probability distribution function, then find CDF and expectation", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "description": "", "name": "tol"}, "e1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4/p^2*(((xu+xl)/2)^3-xl^3)/3", "description": "", "name": "e1"}, "a": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0", "description": "", "name": "a"}, "e2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4/p^2(((xu)^2/2*xu-xu^3/3)-((xu+xl)^2/2*xu-(xl+xu)^3/3))", "description": "", "name": "e2"}, "exans": {"templateType": "anything", "group": "Ungrouped variables", "definition": "up-lo", "description": "", "name": "exans"}, "u": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0..100)", "description": "", "name": "u"}, "xl": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0", "description": "", "name": "xl"}, "j1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round((u*(xu+1)+(100-u)*(2*xu-1))/100)", "description": "", "name": "j1"}, "cval": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(4/p^2,4)", "description": "", "name": "cval"}, "i1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round((t+(100-t)*(xu-1))/100)", "description": "", "name": "i1"}, "ans": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(exans,2)", "description": "", "name": "ans"}, "ux": {"templateType": "anything", "group": "Ungrouped variables", "definition": "j1/2", "description": "", "name": "ux"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0..100)", "description": "", "name": "t"}, "xu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "xl+random(4..15)", "description": "", "name": "xu"}, "lo": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((2/p^2)*(lx-xl)^2,5)", "description": "", "name": "lo"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(xu-xl)", "description": "", "name": "p"}, "up": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-(2/p^2)*(ux-xu)^2,5)", "description": "", "name": "up"}, "lx": {"templateType": "anything", "group": "Ungrouped variables", "definition": "i1/2", "description": "", "name": "lx"}}, "ungrouped_variables": ["a", "e1", "ux", "xl", "i1", "lo", "j1", "up", "exans", "p", "u", "t", "tol", "ans", "e2", "cval", "lx", "xu"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"answer": "{4}/{p^2}", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showCorrectAnswer": true, "expectedvariablenames": [], "notallowed": {"message": "

input as a fraction and not a decimal

", "showStrings": false, "partialCredit": 0, "strings": ["."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "answersimplification": "std", "marks": 2, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$f_X(x) = \\left \\{ \\begin{array}{l} \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\\\\\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}}\\end{array} \\right .$$0$ $ x \\leq \\var{xl},$
$cx$ $\\var{xl} \\lt x \\leq \\simplify[std]{{xu+xl}/2},$
$c(\\var{xu}-x)$ $\\simplify[std]{{xu+xl}/2} \\lt x \\leq \\var{xu},$
$0$$x \\gt \\var{xu}.$
\n \n \n \n

What value of $c$ makes $f_X(x)$ into the pdf of a distribution?

\n \n \n \n

Input your answer here as a fraction and not as a decimal.

\n \n \n \n

$c=\\;\\;$[[0]]

\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"answer": "0", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "checkvariablenames": false, "expectedvariablenames": [], "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "type": "jme", "showCorrectAnswer": true, "marks": 0.5, "vsetrangepoints": 5}, {"answer": "(({2} / {(p ^ 2)}) * ((x + ( - {xl})) ^ 2))", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showCorrectAnswer": true, "expectedvariablenames": [], "notallowed": {"message": "

input numbers as fractions or integers and not as decimals

", "showStrings": false, "partialCredit": 0, "strings": ["."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "answersimplification": "std", "marks": 1, "vsetrangepoints": 5}, {"answer": "(1 + ( - (({2} / {(p ^ 2)}) * ((x + ( - {xu})) ^ 2))))", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showCorrectAnswer": true, "expectedvariablenames": [], "notallowed": {"message": "

input numbers as fractions or integers and not as decimals

", "showStrings": false, "partialCredit": 0, "strings": ["."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "answersimplification": "std", "marks": 1, "vsetrangepoints": 5}, {"answer": "1", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "checkvariablenames": false, "expectedvariablenames": [], "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "type": "jme", "showCorrectAnswer": true, "marks": 0.5, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "\n \n \n

Given the value of $c$ found in the first part, determine and input the distribution function $F_X(x)$

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$F_X(x) = \\left \\{ \\begin{array}{l} \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}}\\\\ \\phantom{{.}}\\\\ \\phantom{{.}} \\end{array} \\right .$ [[0]] $x \\leq \\var{xl},$
[[1]] $\\var{xl} \\lt x \\leq \\simplify[std]{{xu+xl}/2},$
[[2]] $\\simplify[std]{{xu+xl}/2} \\lt x \\leq \\var{xu},$
[[3]] $ x \\gt \\var{xu}.$
\n \n \n \n

Input all numbers as fractions or integers in the above formulae.

\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ans+tol", "minValue": "ans-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n \n \n

Also, using the distribution function above find:

\n \n \n \n

$P(\\var{lx} \\lt X \\lt \\var{ux})=\\;\\;$[[0]]

\n \n \n \n

(input your answer to $2$ decimal places).

\n \n \n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"answer": "{xu}/2", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showCorrectAnswer": true, "expectedvariablenames": [], "notallowed": {"message": "

Input your answer as an integer or a fraction and not as a decimal.

", "showStrings": false, "partialCredit": 0, "strings": ["."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "answersimplification": "all,fractionNumbers", "marks": 1, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "

Hence find the expectation

\n

 $\\displaystyle \\operatorname{E}[X]=\\int_{-\\infty}^{\\infty}xf_X(x)\\;dx$.

\n

$\\operatorname{E}[X]\\;=\\;$[[0]]

\n

Input your answer as an integer or a fraction.

", "showCorrectAnswer": true, "marks": 0}], "statement": "

A random variable $X$ has a probability density function (PDF) given by:

", "tags": ["CFD", "checked2015", "continuous random variables", "cr1", "cumulative distribution functions", "density functions", "distribution function", "distribution functions", "expectation", "integration", "MAS8380", "PDF", "pdf", "piecewise function", "probabilities", "probability density function", "random variables", "statistics", "tested1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

8/07/2012:

\n

Added tags.

\n

Checked calculations, OK.

\n

Set tolerance via new variable tol=0.01 for last question.

\n

23/07/2012:

\n

Added description.

\n

1/08/2012:

\n

Added tags.

\n

In the Advice section, moved \\Rightarrow to the beginning of the line instead of the end of the previous line.

\n

Question appears to be working correctly.

\n

21/12/2012:

\n

Checked calculations, OK. Added tag tested1.

\n

Checked rounding, OK. Added tag cr1.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

The random variable $X$ has a PDF which involves a parameter $c$. Find the value of $c$. Find the distribution function $F_X(x)$ and $P(a \\lt X \\lt b)$.

\n

Also find the expectation $\\displaystyle \\operatorname{E}[X]=\\int_{-\\infty}^{\\infty}xf_X(x)\\;dx$.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

a)
Note that in order for $f_X(x)$ to be a pdf it must satisfy two important conditions:

\n

1. $f_X(x) \\ge 0$ in the range $\\var{xl} \\le x \\le \\var{xu}$

\n

2. The area under the curve given by $f_X(x)$ is $1$ and this implies that:
\\[\\int_{\\var{xl}}^{\\var{xu}}f_X(x)\\;dx = 1\\] as the value of the function is $0$ outside this range.

\n

We first check condition 2. and then check that condition 1. is satisfied.

\n

Hence \\[\\begin{eqnarray*} \\int_{-\\infty}^{\\infty}f_X(x)\\;dx=\\int_{\\var{xl}}^{\\var{xu}}f_X(x)\\;dx&=&\\int_{\\var{xl}}^{\\simplify[std]{{xu+xl}/2}}cx\\;dx+\\int_{\\simplify[std]{{xu+xl}/2}}^{\\var{xu}}c(\\var{xu}-x)\\;dx\\\\
&=&c \\left[ \\frac{x^2}{2} \\right]_{\\var{xl}}^{\\simplify[std]{{xu+xl}/2}} + c\\left[\\var{xu}x - \\frac{x^2}{2}\\right]_{\\simplify[std]{{xu+xl}/2}}^{\\var{xu}}\\\\&=&\\simplify[std]{{(xu+xl)^2}/8}c+\\simplify[std]{{(xu-xl)^2}/8}c=\\simplify[std]{{xu^2+{xl^2}}/{4}}c \\end{eqnarray*} \\]

\n

But this has to equal $1$ and so \\[c=\\simplify[std]{4/{p^2}}\\]

\n

Hence with this value of $c$ we see that condition 2. is satisfied i.e.

\n

\\[\\int_{-\\infty}^{\\infty}f_X(x)\\;dx=1\\]

\n

Condition 1. is clearly satisfied as $c \\gt 0$.

\n

b)

\n

The Distribution Function

\n

We must have $F_X(x)=0,\\;\\;\\;x \\le \\var{xl},\\;\\;\\;\\textrm{and}\\;\\;\\;F_X(x)=1,\\;\\;\\;x \\ge \\var{xu}$

\n

Apart from that we find an expression for $F_X(x)$ in each of the ranges $[\\var{xl},\\simplify[std]{{xl+xu}/2}],\\;\\;\\;[\\simplify[std]{{xl+xu}/2},\\var{xu}]$

\n

1. $x \\in [\\var{xl},\\simplify[std]{{xl+xu}/2}]$

\n

We have:\\[\\begin{eqnarray*} f_X(x) &=& \\simplify[std]{{4}/{p^2}} x \\\\ \\Rightarrow F_X(x)&=& \\int_{-\\infty}^xf_X(u)\\;du \\\\ &=& \\simplify[std]{{4}/{p^2}}\\int_{\\var{xl}}^x u\\;du\\\\ &=&\\simplify[std]{{4}/{p^2}}\\left[\\frac{u^2}{2}\\right]_{\\var{xl}}^x\\\\&=&\\simplify[std]{{2}/{p^2}}x^2 \\end{eqnarray*} \\]

\n

2. $x \\in [\\simplify[std]{{xl+xu}/2},\\var{xu}]$

\n

We have:\\[\\begin{eqnarray*} f_X(x) &=& \\simplify[std]{{4}/{p^2}}(\\var{xu}-x) \\\\ \\Rightarrow  F_X(x)&=& \\int_{-\\infty}^xf_X(u)\\;du = \\int_{\\var{xl}}^{\\simplify[std]{{xl+xu}/2}}f_X(u)\\;du+\\int_{\\simplify[std]{{xl+xu}/2}}^x f_X(u)\\;du\\\\ &=& \\simplify[std]{{4}/{p^2}}\\int_{\\var{xl}}^{\\simplify[std]{{xl+xu}/2}} u\\;du + \\simplify[std]{{4}/{p^2}}\\int_{\\simplify[std]{{xl+xu}/2}}^x(\\var{xu}-u)\\;du\\\\&=&\\simplify[std]{{4}/{p^2}}\\left[ \\frac{u^2}{2} \\right]_{\\var{xl}}^{\\simplify[std]{{xu+xl}/2}} + \\simplify[std]{{4}/{p^2}}\\left[\\var{xu}u - \\frac{u^2}{2}\\right]_{\\simplify[std]{{xu+xl}/2}}^x\\\\&=&1-\\simplify[std]{{2}/{p^2}}(\\var{xu}-x)^2 \\end{eqnarray*} \\]

\n

c)

\n

Probability

\n

Using the distribution function we have just found we have that:

\n

$P(\\var{lx} \\lt X \\lt \\var{ux}) = F_X(\\var{ux})-F_X(\\var{lx})$

\n

But $\\var{ux}$ is in the range between $\\var{(xl+xu)/2}$ and $\\var{xu}$ and the distribution function is given by:

\n

\\[F_X(x)=1-\\simplify[std]{{2}/{p^2}}(\\var{xu}-x)^2\\]

\n

Hence $F_X(\\var{ux})=1-\\simplify[std]{{2}/{p^2}}(\\var{xu}-\\var{ux})^2 = \\var{up}$ to 5 decimal places.

\n

Similarly, $\\var{lx}$ is in the range between $\\var{xl}$ and $\\var{(xl+xu)/2}$ and the distribution function is given by:

\n

\\[F_X(x)=\\simplify[std]{{2}/{p^2}}x^2\\]

\n

Hence $F_X(\\var{lx})=\\simplify[std]{{2}/{p^2}}(\\var{lx})^2 = \\var{lo}$ to 5 decimal places.

\n

Hence $P(\\var{lx} \\lt X \\lt \\var{ux}) = F_X(\\var{ux})-F_X(\\var{lx})=\\var{up}-\\var{lo}=\\var{up-lo}=\\var{ans}$ to 2 decimal places.

\n

Expectation.

\n

d) The expectation is given by  $\\displaystyle \\operatorname{E}[X]=\\int_{-\\infty}^{\\infty}xf_X(x)\\;dx$.

\n

As $f_X(x)=0$ for $x \\le \\var{xl}$ and $x \\ge \\var{xu}$ we see that:

\n

\\[\\begin{align}\\operatorname{E}[X]= \\int_{-\\infty}^{\\infty}xf_X(x)\\;dx &= \\int_{\\var{xl}}^{\\simplify[std]{{(xu+xl)}/2}}xf_X(x)\\;dx+ \\int_{\\simplify[std]{{(xu+xl)}/2}}^{\\var{xu}}xf_X(x)\\;dx\\\\&= c\\int_{\\var{xl}}^{\\simplify[std]{{(xu+xl)}/2}}x^2\\;dx+c\\int_{\\simplify[std]{{(xu+xl)}/2}}^{\\var{xu}}x({\\var{xu}-x)}\\;dx\\\\&=c \\left[ \\frac{x^3}{3} \\right]_{\\var{xl}}^{\\simplify[std]{{xu+xl}/2}} + c\\left[\\var{xu}\\frac{x^2}{2} - \\frac{x^3}{3}\\right]_{\\simplify[std]{{xu+xl}/2}}^{\\var{xu}}\\\\&=c\\times\\simplify[std]{{xu}^3/24}+c\\times \\simplify[std]{{xu}^3/12}\\\\&=\\simplify[std]{{xu}/2}\\end{align}\\]

\n

on remembering that $\\displaystyle c=\\simplify[std]{4/{p^2}}$

"}, {"name": "Find expectation, variance and CDF of uniform distribution", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "ans2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((upper-lower)^2/12,3)", "description": "", "name": "ans2"}, "ans3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((c-lower)/(upper-lower),3)", "description": "", "name": "ans3"}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(d1=f1,d1-1,min(d1,f1))", "description": "", "name": "d"}, "f1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round((upper-lower-2)*random(0..60)/60+lower)", "description": "", "name": "f1"}, "f": {"templateType": "anything", "group": "Ungrouped variables", "definition": "max(d1,f1)", "description": "", "name": "f"}, "ans1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(upper+lower)/2", "description": "", "name": "ans1"}, "d1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round((upper-lower-2)*random(0..60)/60+lower+1)", "description": "", "name": "d1"}, "ans4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((f-d)/(upper-lower),3)", "description": "", "name": "ans4"}, "upper": {"templateType": "anything", "group": "Ungrouped variables", "definition": "lower+random(2..20#2)", "description": "", "name": "upper"}, "lower": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(-10..10)", "description": "", "name": "lower"}, "c": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round((upper-lower-2)*random(0..60)/60+lower+1)", "description": "", "name": "c"}}, "ungrouped_variables": ["upper", "lower", "ans3", "d", "f1", "ans1", "ans2", "f", "ans4", "c", "tol", "d1"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ans1", "minValue": "ans1", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ans2+tol", "minValue": "ans2-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

The expectation $\\operatorname{E}[Y]=\\;?$[[0]]  (to 3 decimal places).

\n

 The variance $\\operatorname{Var}(Y)=\\;$?[[1]]  (to 3 decimal places).

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"answer": "(y-{lower})/({upper-lower})", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showCorrectAnswer": true, "expectedvariablenames": [], "notallowed": {"message": "

Input all numbers as fractions or integers.

", "showStrings": false, "partialCredit": 0, "strings": ["."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "answersimplification": "basic", "marks": 1, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "

Input the CDF $F_Y(y)$ for $y$ in the range $\\var{lower} \\le y \\le \\var{upper}$

\n

$F_Y(y)=\\;$?[[0]]

\n

Input all numbers as fractions or integers

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ans4+tol", "minValue": "ans4-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

$P(\\var{d} \\lt Y \\lt \\var{f})=\\;$?[[0]]

\n

\n

Enter your answer to 3 decimal places.

", "showCorrectAnswer": true, "marks": 0}], "statement": "

Let $Y$ be a random variable with the uniform distribution

\n

\\[Y \\sim \\operatorname{U}(\\var{lower},\\var{upper})\\]

", "tags": ["CDF uniform", "checked2015", "continuous distributions", "expectation", "MAS8380", "Probability", "probability", "sc", "statistical distributions", "uniform distribution", "uniformly distributed", "variance"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

25/01/2013:

\n

Copy made of 1403CBA3Q5 and then edited.

\n

Added fourth part.

\n

To be tested.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Exercise using a given uniform distribution $Y$, calculating the expectation and variance as well as asking for the CDF. Also finding  $P( b \\lt Y \\lt c)$ for given values of $b,\\;c$.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

a) For a Uniform distribution \\[Y \\sim \\operatorname{U}(\\var{lower},\\var{upper})\\] we have:

\n

$\\displaystyle \\operatorname{E}[Y] = \\simplify[!collectNumbers]{({lower}+{upper})/2}=\\var{ans1}$

\n

$\\displaystyle \\operatorname{Var}(Y) =\\simplify[basic,!collectNumbers,!noleadingminus]{({upper}-{lower})^2/12}=\\frac{\\var{upper-lower}^2}{12}=\\var{ans2}$ to 3 decimal places.

\n

\n

b) The CDF for a uniform distribution $Y$ on the interval $a \\le y \\le b$ is given by:

\n

\\[F_Y(y) = \\begin{cases} 0 & y \\lt a \\\\ \\frac{y-a}{b-a} & a \\le y \\le b, \\\\ 1 & y \\gt b. \\end{cases}\\]

\n

 Hence in this case we have:

\n

\\[F_Y(y) = \\simplify[basic]{(y-{lower})/({upper-lower})}\\] for $\\var{lower}\\le y \\le \\var{upper}$

\n

c) Using the CDF we have:

\n

\\[\\begin{eqnarray}P(\\var{d} \\lt Y \\lt \\var{f})&=&F_Y(\\var{f})-F_Y(\\var{d})\\\\&=&   \\simplify[basic]{({f}-{lower})/({upper-lower})- ({d}-{lower})/({upper-lower})}\\\\&=&\\var{ans4}\\end{eqnarray}\\]

\n

to 3 decimal places.

"}, {"name": "Expectation and variance of combinations of estimators", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"b": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'B'", "name": "b", "description": ""}, "e3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "s3*m", "name": "e3", "description": ""}, "unb2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(unb1=0,1,random(0,1))", "name": "unb2", "description": ""}, "s7": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1,-1)", "name": "s7", "description": ""}, "sqsum1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "cw1^2+cx1^2+cy1^2+cz1^2", "name": "sqsum1", "description": ""}, "wrong": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(unb1*unb2>0,'C',if(unb1=1,'B','A'))", "name": "wrong", "description": ""}, "t3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(unb3=1,1,random(2..9))", "name": "t3", "description": ""}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sqsum1*sd^2", "name": "v1", "description": ""}, "su2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "cw2+cx2+cy2+cz2", "name": "su2", "description": ""}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random('W','X','Y','Z')", "name": "p", "description": ""}, "cy1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(cx1=0,random(1..9),random(-9..9))", "name": "cy1", "description": ""}, "sd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..6)", "name": "sd", "description": ""}, "cw1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..9)", "name": "cw1", "description": ""}, "t1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(unb1=1,1,random(2..9))", "name": "t1", "description": ""}, "tw": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0,1)", "name": "tw", "description": ""}, "cy3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..9)", "name": "cy3", "description": ""}, "sqsum2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "cw2^2+cx2^2+cy2^2+cz2^2", "name": "sqsum2", "description": ""}, "v3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sqsum3*sd^2", "name": "v3", "description": ""}, "s1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "cw1+cx1+cy1+cz1", "name": "s1", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "a": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'A'", "name": "a", "description": ""}, "c": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'C'", "name": "c", "description": ""}, "sqsum3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "cw3^2+cx3^2+cy3^2+cz3^2", "name": "sqsum3", "description": ""}, "s2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(unb2=1,su2,su2+random(1..4))", "name": "s2", "description": ""}, "unb1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0,1)", "name": "unb1", "description": ""}, "cz3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "t3-cw3-cx3-cy3", "name": "cz3", "description": ""}, "cx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..9)", "name": "cx2", "description": ""}, "cw3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tw*random(10..40)", "name": "cw3", "description": ""}, "sx": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1,-1)", "name": "sx", "description": ""}, "correct2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(unb1=1,if(unb2=1,'B','C'),'C')", "name": "correct2", "description": ""}, "cw2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..9)", "name": "cw2", "description": ""}, "q": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(p='X',random('W','Y','Z'),p='W',random('X','Y','Z'),p='Y',random('W','X','Z'),random('W','X','Y'))", "name": "q", "description": ""}, "e2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(su2*m/S2,2)", "name": "e2", "description": ""}, "e1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "s1*m", "name": "e1", "description": ""}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "s7*random(1..10)", "name": "m", "description": ""}, "correct1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(unb1=1,'A','B')", "name": "correct1", "description": ""}, "cz2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..9)", "name": "cz2", "description": ""}, "unb3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(unb1*unb2>0,0,1)", "name": "unb3", "description": ""}, "cy2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..9)", "name": "cy2", "description": ""}, "cx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(-9..9)", "name": "cx1", "description": ""}, "s3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "cw3+cx3+cy3+cz3", "name": "s3", "description": ""}, "v2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqsum2*sd^2/S2^2,2)", "name": "v2", "description": ""}, "cx3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tx*sx*random(1..9)", "name": "cx3", "description": ""}, "cz1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "t1-cx1-cw1-cy1", "name": "cz1", "description": ""}, "tx": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tw=0,1,0)", "name": "tx", "description": ""}}, "ungrouped_variables": ["cy3", "cy2", "cy1", "t3", "correct2", "correct1", "t1", "unb3", "unb2", "unb1", "s3", "tw", "s1", "s7", "tol", "cx1", "cx2", "cx3", "sqsum1", "sqsum3", "sqsum2", "cz2", "cz3", "cz1", "v1", "v2", "v3", "e1", "e3", "e2", "a", "c", "b", "tx", "cw1", "cw3", "cw2", "m", "wrong", "sx", "q", "p", "su2", "s2", "sd"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "showQuestionGroupNames": false, "functions": {}, "parts": [{"scripts": {}, "gaps": [{"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{e1}", "correctAnswerFraction": false, "marks": 1, "maxValue": "{e1}"}, {"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{v1}", "correctAnswerFraction": false, "marks": 1, "maxValue": "{v1}"}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "

$\\simplify[std]{A = {cw1} * W + {cx1} * X + {cy1} * Y + {cz1} * Z}$

\n

$ \\operatorname{E}[A]=\\;\\;$[[0]]$\\;\\;\\;\\;\\operatorname{Var}(A)=\\;\\;\\;$[[1]]

\n

Input both as integers.

", "marks": 0}, {"scripts": {}, "gaps": [{"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{e2-tol}", "correctAnswerFraction": false, "marks": 1, "maxValue": "{e2+tol}"}, {"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{v2-tol}", "correctAnswerFraction": false, "marks": 1, "maxValue": "{v2+tol}"}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "

$\\simplify[std]{B = (1 / {S2}) * ({cw2} * W + {cx2} * X + {cy2} * Y + {cz2} * Z)}$

\n

$\\operatorname{E}[B]=\\;\\;$[[0]]$\\;\\;\\;\\;\\operatorname{Var}(B)=\\;\\;\\;$[[1]]

\n

Input both to 2 decimal places.

", "marks": 0}, {"scripts": {}, "gaps": [{"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{e3}", "correctAnswerFraction": false, "marks": 1, "maxValue": "{e3}"}, {"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{v3}", "correctAnswerFraction": false, "marks": 1, "maxValue": "{v3}"}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "

$\\simplify[std]{C = {cw3} * W + {cx3} * X + {cy3} * Y + {cz3} * Z}$

\n

$ \\operatorname{E}[C]=\\;\\;$[[0]]$\\;\\;\\;\\;\\operatorname{Var}(C)=\\;\\;\\;$[[1]]

\n

Input both as integers.

", "marks": 0}, {"scripts": {}, "gaps": [{"displayType": "checkbox", "choices": ["

$\\var{Correct1}$

", "

$\\var{Correct2}$

", "

$\\var{Wrong}$

"], "matrix": [1, 1, -1], "distractors": ["", "", ""], "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": true, "scripts": {}, "maxMarks": 0, "type": "m_n_2", "minMarks": 0, "showCorrectAnswer": true, "displayColumns": 3, "marks": 0}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "\n \n \n

Which of the estimators $A,\\;\\;B$ or $C$ above are unbiased for $\\mu$? Select the correct choices.
You will lose a mark for selecting a wrong choice.

\n \n \n \n

[[0]]

\n \n ", "marks": 0}, {"scripts": {}, "gaps": [{"displayType": "radiogroup", "choices": ["

$\\var{B}$

", "

$\\var{A}$

", "

$\\var{C}$

"], "matrix": [1, 0, 0], "distractors": ["", "", ""], "shuffleChoices": true, "scripts": {}, "maxMarks": 0, "type": "1_n_2", "minMarks": 0, "showCorrectAnswer": true, "displayColumns": 3, "marks": 0}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "\n \n \n

Which of the estimators $A,\\;\\;B$ or $C$ above is the most efficient?

\n \n \n \n

[[0]]

\n \n ", "marks": 0}, {"scripts": {}, "gaps": [{"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{m^2}", "correctAnswerFraction": false, "marks": 1, "maxValue": "{m^2}"}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "

Find $\\operatorname{E}[\\var{p}\\var{q}]=\\;\\;$[[0]]

", "marks": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

Suppose $W,\\;\\;X,\\;\\;Y,\\;\\;$ and $Z$ are i.i.d. variables with mean $\\mu=\\var{m}$, standard deviation $\\sigma=\\var{sd}$

\n

Find the expectation and variance of each of the following estimators of $\\mu$.

", "tags": ["IID", "MAS1604", "biased", "checked2015", "cr1", "efficient estimators", "estimators", "expectation", "i.i.d", "identical independent distributions", "iid", "independent identical distributions", "mean ", "random variables", "standard deviation", "statistics", "tested1", "unbiased", "unbiased estimators", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

13/07/2012:

\n

Added tags.

\n

Improved and made consistent the display in various content areas.

\n

Set new tolerance variable tol=0 for 2 dps numeric input questions.

\n

Added formula for $\\operatorname{Var}(aR+bS)$.

\n

Checked calculation.

\n

Added description.

\n

1/08/2012:

\n

Added tags.

\n

Question appears to be working correctly.

\n

21/12/2012:

\n

Checked calculation, OK. Added tested1 tag.

\n

Checked rounding, OK. Added tag cr1.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Given three linear combinations of four i.i.d. variables, find the expectation and variance of these estimators of the mean $\\mu$. Which are unbiased and efficient?

"}, "advice": "

We use the result throughout these solutions that for independent random variables $R$ and $S$ then $\\operatorname{E}[aR+bS]=a \\operatorname{E}[R]+b\\operatorname{E}[S]$ and $\\operatorname{Var}(aR+bS)=a^2\\operatorname{Var}(R)+b^2\\operatorname{Var}(S)$.

\n

a)
\\[\\begin{eqnarray*} \\operatorname{E}[A] &=& \\operatorname{E}[\\simplify[std]{{cw1} * W + {cx1} * X + {cy1} * Y + {cz1} * Z}]\\\\ &=& \\simplify[std]{{cw1} * {m} + {cx1} * {m} + {cy1} * {m} + {cz1} * {m}}\\\\ &=& \\var{e1}\\\\ \\\\ \\\\ \\operatorname{Var}(A) &=& \\operatorname{Var}[\\simplify[std]{{cw1} * W + {cx1} * X + {cy1} * Y + {cz1} * Z}]\\\\ &=& \\simplify[std]{ {cw1 ^ 2} * Var(W) + {cx1 ^ 2} * Var(X) + {cy1 ^ 2} * Var(Y) + {cz1 ^ 2} * Var(Z)}\\\\ &=& \\simplify[std]{{cw1 ^ 2} * {sd ^ 2} + {cx1 ^ 2} * {sd ^ 2} + {cy1 ^ 2} * {sd ^ 2} + {cz1 ^ 2} * {sd ^ 2} }\\\\ &=& \\var{v1} \\end{eqnarray*} \\]

\n

b)
\\[\\begin{eqnarray*} \\operatorname{E}[B] &=& \\frac{1}{\\var{S2}}\\left(\\operatorname{E}[\\simplify[std]{{cw2} * W + {cx2} * X + {cy2} * Y + {cz2} * Z}]\\right)\\\\ &=& \\frac{1}{\\var{S2}}\\left(\\simplify[std]{{cw2} * {m} + {cx2} * {m} + {cy2} * {m} + {cz2} * {m}}\\right)\\\\ &=& \\var{e2}\\\\ \\\\ \\\\ \\operatorname{Var}(B) &=& \\frac{1}{\\var{S2^2}}\\left(\\operatorname{Var}[\\simplify[std]{{cw2} * W + {cx2} * X + {cy2} * Y + {cz2} * Z}]\\right)\\\\ &=& \\frac{1}{\\var{S2^2}}\\left(\\simplify[std]{ {cw2 ^ 2} * Var(W) + {cx2 ^ 2} * Var(X) + {cy2 ^ 2} * Var(Y) + {cz2 ^ 2} * Var(Z)}\\right)\\\\ &=& \\frac{1}{\\var{S2^2}}\\left(\\simplify[std]{{cw2 ^ 2} * {sd ^ 2} + {cx2 ^ 2} * {sd ^ 2} + {cy2 ^ 2} * {sd ^ 2} + {cz2 ^ 2} * {sd ^ 2} }\\right)\\\\ &=& \\var{v2} \\end{eqnarray*} \\]
c)
\\[\\begin{eqnarray*} \\operatorname{E}[C] &=& \\operatorname{E}[\\simplify[std,collectNumbers]{{cw3} * W + {cx3} * X + {cy3} * Y + {cz3} * Z}]\\\\ &=& \\simplify[std,collectNumbers]{{cw3} * {m} + {cx3} * {m} + {cy3} * {m} + {cz3} * {m}}\\\\ &=& \\var{e3}\\\\ \\\\ \\\\ \\operatorname{Var}(C) &=& \\operatorname{Var}[\\simplify[std]{{cw3} * W + {cx3} * X + {cy3} * Y + {cz3} * Z}]\\\\ &=& \\simplify[std]{ {cw3 ^ 2} * Var(W) + {cx3 ^ 2} * Var(X) + {cy3 ^ 2} * Var(Y) + {cz3 ^ 2} * Var(Z)}\\\\ &=& \\simplify[std]{{cw3 ^ 2} * {sd ^ 2} + {cx3 ^ 2} * {sd ^ 2} + {cy3 ^ 2} * {sd ^ 2} + {cz3 ^ 2} * {sd ^ 2} }\\\\ &=& \\var{v3} \\end{eqnarray*} \\]

\n

d)

\n

We see that $\\var{Correct1},\\;\\;\\var{Correct2}\\;\\;$ are unbiased estimators for $\\mu=\\var{m}$ as their expectations are $\\var{m}$.

\n

e)

\n

The most efficient estimator is $B$ as it has the smallest variance.

\n

f)
Since $\\var{p}$ and $\\var{q}$ are independent we have:

\n

$\\operatorname{E}[\\var{p}\\var{q}]=\\operatorname{E}[\\var{p}]\\operatorname{E}[\\var{q}] = \\var{m}\\times \\var{m} = \\var{m^2}$

"}, {"name": "Find a confidence interval given the mean of a sample", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Vicky Hall", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/659/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "tags": ["checked2015"], "metadata": {"description": "

Finding the confidence interval at either 90%, 95% or 99% for the mean given the mean of a sample. The population variance is given and so the z values are used. Various scenarios are included.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

A company {sc[s]} {dothis[s]} $\\var{sd[s]}$ $\\var{units}^2$.

\n

A random sample of $\\var{n}$ {t[s]} gives a mean  of $\\var{m[s]}$ {units}. 

\n

 

", "advice": "

a)

\n

We use the standard normal distribution (rather than the t-distribution) to find the confidence interval as we know the population variance.

\n

We now calculate the $\\var{confl}$% confidence interval.

\n

Note that $z_{\\var{con}}=\\var{zval}$ and the confidence interval is given by:

\n

\\[ \\var{m[s]} \\pm z_{\\var{con}}\\sqrt{\\frac{\\var{sd2}}{\\var{n}}}\\]

\n

Hence:

\n

Lower value of the confidence interval $=\\;\\displaystyle \\var{m[s]} -\\var{zval} \\sqrt{\\frac{\\var{sd2}} {\\var{n}}} = \\var{lci}${units} to 2 decimal places.

\n

Upper value of the confidence interval $=\\;\\displaystyle \\var{m[s]} +\\var{zval} \\sqrt{\\frac{\\var{sd2}} {\\var{n}}} = \\var{uci}${units} to 2 decimal places.

\n

b)

\n

Since $\\var{aim}$ {doornot} {lies} in the confidence interval the answer is {Correct}.

\n

 

", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"aim": {"name": "aim", "group": "Ungrouped variables", "definition": "if(s=0,750,if(s=1,100,if(s=2,100,1500)))", "description": "", "templateType": "anything", "can_override": false}, "confl": {"name": "confl", "group": "Ungrouped variables", "definition": "random(90,95,99)", "description": "", "templateType": "anything", "can_override": false}, "sc4ch": {"name": "sc4ch", "group": "Ungrouped variables", "definition": "random(\"supermarkets\",\"clothing retailers\",\"department stores\",\"fast food outlets\")", "description": "", "templateType": "anything", "can_override": false}, "sd1": {"name": "sd1", "group": "Ungrouped variables", "definition": "if(s=3,sd[s],sqrt(sd[s]))", "description": "", "templateType": "anything", "can_override": false}, "doornot": {"name": "doornot", "group": "Ungrouped variables", "definition": "if(test=0, \" \",\"does not\")", "description": "", "templateType": "anything", "can_override": false}, "lies": {"name": "lies", "group": "Ungrouped variables", "definition": "if(test=0,\"lies\",\"lie\")", "description": "", "templateType": "anything", "can_override": false}, "howwell": {"name": "howwell", "group": "Ungrouped variables", "definition": "\n [\"On average, is the company reaching its target of 750g per bag?\",\n \"The bolts are designed to be 100mm long. Is the process satisfactory?\",\n \"The vending machines are supposed to fill 100ml cups. Is the machine working satisfactorily?\"\n ]\n ", "description": "", "templateType": "anything", "can_override": false}, "correct": {"name": "correct", "group": "Ungrouped variables", "definition": "if(test=0, \"yes\", \"no\")", "description": "", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "random(20..100)", "description": "", "templateType": "anything", "can_override": false}, "t": {"name": "t", "group": "Ungrouped variables", "definition": "\n [\"bags \",\n sc2ch,\n \"filled cups \"\n]\n \n \n ", "description": "", "templateType": "anything", "can_override": false}, "sc2ch": {"name": "sc2ch", "group": "Ungrouped variables", "definition": "random(\"bolts\",\"screws\")", "description": "", "templateType": "anything", "can_override": false}, "dothis": {"name": "dothis", "group": "Ungrouped variables", "definition": "\n [var1 + \" is\",\n \"with a \"+var2+\" of\",\n var3+ \" is\"]\n \n \n \n \n ", "description": "", "templateType": "anything", "can_override": false}, "var3": {"name": "var3", "group": "Ungrouped variables", "definition": "random(\"The variance of the filling process \",\"The process variance \")", "description": "", "templateType": "anything", "can_override": false}, "sc1ch": {"name": "sc1ch", "group": "Ungrouped variables", "definition": "random(\"flour.\",\"sugar.\",\"dried milk.\",\"instant coffee.\")", "description": "", "templateType": "anything", "can_override": false}, "sc": {"name": "sc", "group": "Ungrouped variables", "definition": "\n [\"packs sacks of \"+sc1ch,\n \"manufactures \"+sc2ch,\n \"produces vending machines which fill cups with \"+sc3ch\n\n ]\n \n ", "description": "", "templateType": "anything", "can_override": false}, "mm": {"name": "mm", "group": "Ungrouped variables", "definition": "[1-test,test]", "description": "", "templateType": "anything", "can_override": false}, "sc3ch": {"name": "sc3ch", "group": "Ungrouped variables", "definition": "random(\"hot water.\",\"tea.\",\"coffee.\",\"hot chocolate.\",\"cappuccino.\")", "description": "", "templateType": "anything", "can_override": false}, "var2": {"name": "var2", "group": "Ungrouped variables", "definition": "random(\"process variance \",\"population variance \")", "description": "", "templateType": "anything", "can_override": false}, "m": {"name": "m", "group": "Ungrouped variables", "definition": "\n [random(700..745),\n random(95..98),\n random(90..99)]\n \n \n ", "description": "", "templateType": "anything", "can_override": false}, "lci": {"name": "lci", "group": "Ungrouped variables", "definition": "precround(tlci,2)", "description": "", "templateType": "anything", "can_override": false}, "uci": {"name": "uci", "group": "Ungrouped variables", "definition": "precround(tuci,2)", "description": "", "templateType": "anything", "can_override": false}, "units": {"name": "units", "group": "Ungrouped variables", "definition": "switch(s=0,\"g\",s=1,\"mm\",s=2,\"ml\",\"pounds\")", "description": "", "templateType": "anything", "can_override": false}, "tuci": {"name": "tuci", "group": "Ungrouped variables", "definition": "m[s]+zval*sqrt(sd1^2/n)", "description": "", "templateType": "anything", "can_override": false}, "zval": {"name": "zval", "group": "Ungrouped variables", "definition": "if(confl=90,1.645,if(confl=95,1.96,2.576))", "description": "", "templateType": "anything", "can_override": false}, "test": {"name": "test", "group": "Ungrouped variables", "definition": "if(aim lci,0,1)", "description": "", "templateType": "anything", "can_override": false}, "sd": {"name": "sd", "group": "Ungrouped variables", "definition": "\n [random(800..1400#20),\n random(1200..1800#20),\n random(300..600#20),\n random(100..200#0.1)]\n \n ", "description": "", "templateType": "anything", "can_override": false}, "spec": {"name": "spec", "group": "Ungrouped variables", "definition": "if(s=2,\"the timecards of \", \" \")", "description": "", "templateType": "anything", "can_override": false}, "s": {"name": "s", "group": "Ungrouped variables", "definition": "random(0..abs(sc)-1)", "description": "", "templateType": "anything", "can_override": false}, "con": {"name": "con", "group": "Ungrouped variables", "definition": "(confl)/100", "description": "", "templateType": "anything", "can_override": false}, "tlci": {"name": "tlci", "group": "Ungrouped variables", "definition": "m[s]-zval*sqrt(sd1^2/n)", "description": "", "templateType": "anything", "can_override": false}, "var1": {"name": "var1", "group": "Ungrouped variables", "definition": "random(\"The variance of the filling process \",\"The process variance \")", "description": "", "templateType": "anything", "can_override": false}, "sd2": {"name": "sd2", "group": "Ungrouped variables", "definition": "if(s=3,sd[s]^2,sd[s])", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["sd1", "sd2", "howwell", "n", "doornot", "uci", "test", "confl", "spec", "var1", "var3", "var2", "sc2ch", "units", "zval", "sc1ch", "lci", "tuci", "lies", "mm", "dothis", "sc4ch", "correct", "m", "aim", "sc3ch", "tlci", "s", "t", "sc", "con", "sd"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "\n

Calculate a  $\\var{confl}$% confidence interval $(a,b)$ for the population mean:

\n

$a=\\;$[[0]]{units}          $b=\\;$[[1]]{units}

\n

Enter both to 2 decimal places.

\n

 

\n ", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "lci-0.05", "maxValue": "lci+0.05", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "uci-0.05", "maxValue": "uci+0.05", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "\n

{howwell[s]}

\n

[[0]]

\n ", "gaps": [{"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["Yes", "No"], "matrix": "mm"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Perform t-test given sample mean and standard deviation", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "dmm": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(pval2<0.05,[0,1],[1,0])", "description": "", "name": "dmm"}, "thisamount": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(70..90)", "description": "", "name": "thisamount"}, "confl": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(90,95,99)", "description": "", "name": "confl"}, "pval": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pval2>0.1,0,pval2>0.05,1,pval2>0.01,2,3)", "description": "", "name": "pval"}, "correctc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(pval2<0.05,\"There is sufficient evidence against the claim of the flight company.\",\"There is insufficient evidence against the claim of the flight company.\")", "description": "", "name": "correctc"}, "tval1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(meandata-thisamount)*sqrt(n)/stdata", "description": "", "name": "tval1"}, "this": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"An online flight company makes the following claim:\"", "description": "", "name": "this"}, "data": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(m,stand)),n)", "description": "", "name": "data"}, "stdata": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stdev(data,true),2)", "description": "", "name": "stdata"}, "dothis": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pval2 <=0.05, 'reject','retain')", "description": "", "name": "dothis"}, "tval": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(tval1,3)", "description": "", "name": "tval"}, "meandata": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(data),2)", "description": "", "name": "meandata"}, "mm": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pval2>0.1,[1,0,0,0],pval2>0.05,[0,1,0,0],pval2>0.01,[0,0,1,0],[0,0,0,1])", "description": "", "name": "mm"}, "here": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(\"Barcelona\",\"Madrid\",\"Athens\",\"Berlin\",\"Palma\",\"Rome\",\"Paris\",\"Lisbon\")", "description": "", "name": "here"}, "things": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"customers is taken.\"", "description": "", "name": "things"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "thisamount+random(-15..15 except [-5..5])", "description": "", "name": "m"}, "claim": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"The average cost of a flight with us to \"+ here + \" is just \u00a3\" + {thisamount} + \" (including all taxes and charges!)\"", "description": "", "name": "claim"}, "evi1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[\"no\",\"slight\",\"moderate\",\"strong\"]", "description": "", "name": "evi1"}, "test": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"A rival flight company decides to test their claim.\"", "description": "", "name": "test"}, "fac": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(pval2>0.05,\"There is sufficient evidence against the claim of the flight company\",\"There is insufficient evidence against the claim of the flight company.\")", "description": "", "name": "fac"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..30)", "description": "", "name": "n"}, "evi": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[\"None\",\"Slight\",\"Moderate\",\"Strong\"]", "description": "", "name": "evi"}, "stand": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(15..25)", "description": "", "name": "stand"}, "resultis": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\"The mean cost of a flight to \"+ here + \" from this sample is \"", "description": "", "name": "resultis"}, "pval2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(2*studenttcdf(-abs(tval),n-1),3)", "description": "", "name": "pval2"}}, "ungrouped_variables": ["claim", "pval", "evi1", "meandata", "tval1", "things", "tol", "test", "tval", "correctc", "pval2", "resultis", "here", "stdata", "fac", "data", "confl", "evi", "this", "dothis", "m", "dmm", "n", "mm", "thisamount", "stand"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "thisamount", "minValue": "thisamount", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "thisamount", "minValue": "thisamount", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n

Step 1: Null Hypothesis

\n

$\\operatorname{H}_0\\;: \\; \\mu=\\;$[[0]]

\n

Step 2: Alternative Hypothesis

\n

$\\operatorname{H}_1\\;: \\; \\mu \\neq\\;$[[1]]

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "meandata+tol", "minValue": "meandata-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "stdata+tol", "minValue": "stdata-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Calculate the mean and standard deviation of the sample data, both to 2 decimal places:

\n

\n

Sample mean=[[0]]  (2 decimal places)

\n

\n

Sample standard deviation = [[1]]  (2 decimal places)

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "tval+tol", "minValue": "tval-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Step 3: Test statistic

\n

Using your calculated values for the mean and standard deviation, calculate the test statistic = ? [[0]] (to 3 decimal places)

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "pval2+0.001", "minValue": "pval2-0.001", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Step 4: p-value

\n

Use R to compute your $p$-value using the value, to 3 decimal places, of the test statistic you have found.

\n

$p$-value= [[0]] (to 3 decimal places)

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"displayType": "radiogroup", "choices": ["{evi[0]}", "{evi[1]}", "{evi[2]}", "{evi[3]}"], "displayColumns": 0, "distractors": ["", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "mm", "marks": 0}, {"displayType": "radiogroup", "choices": ["Retain", "Reject"], "displayColumns": 0, "distractors": ["", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "dmm", "marks": 0}, {"displayType": "radiogroup", "choices": ["{Correctc}", "{Fac}"], "displayColumns": 0, "distractors": ["", ""], "shuffleChoices": true, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": [1, 0], "marks": 0}], "type": "gapfill", "prompt": "

Step 5: Conclusion

\n

 

\n

Given the $p$ - value, what is the strength of evidence against the null hypothesis?

\n

[[0]]

\n

Your Decision:

\n

[[1]]

\n

 

\n

Conclusion:

\n

[[2]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

{this} 

\n

{claim}

\n

{test}

\n

A sample of {n} {things} and the following prices charged in £ were found:

\n

{data}

\n

Perform an appropriate hypothesis test to see if the claim made by the online flight company is substantiated (use a two-tailed test).

", "tags": ["accept null hypothesis", "alternative hypothesis", "checked2015", "critical value", "decision", "degree of freedom", "diagram", "evidence", "hypothesis testing", "MAS8380", "null hypothesis", "p value", "population variance", "probability", "Probability", "random sample", "reject null hypothesis", "sample mean", "sample standard deviation", "sampling", "sc", "statistics", "t tables", "t test", "test statistic", "two-tailed test"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

2/01/2012:

\n \t\t

Added tag sc as has string variables in order to generate other scenarios.

\n \t\t

The jstat function studenttinv(critvalue,n-1) gives the critical p values correctly.

\n \t\t

Added tag diagram as the i-assess question advice has a nice graphic of the p-value and the appropriate decision.

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Provided with information on a sample with sample mean and standard deviation, but no information on the population variance, use the t test to either accept or reject a given null hypothesis.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

a)

\n

Step 1: Null Hypothesis

\n

$\\operatorname{H}_0\\;: \\; \\mu=\\;\\var{thisamount}$

\n

Step 2: Alternative Hypothesis

\n

$\\operatorname{H}_1\\;: \\; \\mu \\neq\\;\\var{thisamount}$

\n

b)

\n

We find the sample mean is $\\var{meandata}$ to 2 decimal places.

\n

The sample standard deviation is $\\var{stdata}$ to 2 decimal places.

\n

c)

\n

We should use the t statistic as the population variance is unknown.

\n

The test statistic:

\n

\\[t =\\frac{ \\var{meandata} -\\var{thisamount}} {\\frac{\\var{stdata} }{\\sqrt{\\var{n}}}} = \\var{tval}\\]

\n

to 3 decimal places.

\n

d)

\n

Using the R function $\\operatorname{pt}$ with df set to $\\var{n-1}$ we find the  $p$ value =$\\var{pval2}$ to 3 decimal places.

\n


e)

\n

Hence there is {evi1[pval]} evidence against $\\operatorname{H}_0$ and so we {dothis} $\\operatorname{H}_0$.

\n

{Correctc}

"}], "name": "", "pickQuestions": 0}], "name": "Mathematics and statistics for computer scientists", "showQuestionGroupNames": false, "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Questions used in a university course titled \"Mathematics and statistics for computer scientists\""}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "extensions": ["stats"], "custom_part_types": [], "resources": []}