// Numbas version: exam_results_page_options {"name": "Leonardo's copy of Mean, SD, median and IQR", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "functions": {}, "variables": {"lquartile": {"description": "", "name": "lquartile", "group": "Ungrouped variables", "templateType": "anything", "definition": "0.75*r1[5]+0.25*r1[6]"}, "n": {"description": "", "name": "n", "group": "Ungrouped variables", "templateType": "anything", "definition": "24"}, "units": {"description": "", "name": "units", "group": "Ungrouped variables", "templateType": "anything", "definition": "'grams'"}, "r0": {"description": "", "name": "r0", "group": "Ungrouped variables", "templateType": "anything", "definition": "repeat(random(l..u),24)"}, "l": {"description": "", "name": "l", "group": "Ungrouped variables", "templateType": "anything", "definition": "random(10..19)"}, "stdev": {"description": "", "name": "stdev", "group": "Ungrouped variables", "templateType": "anything", "definition": "precround(stdev(r0,true),2)"}, "mean": {"description": "", "name": "mean", "group": "Ungrouped variables", "templateType": "anything", "definition": "mean(r0)"}, "var": {"description": "", "name": "var", "group": "Ungrouped variables", "templateType": "anything", "definition": "variance(r0,true)"}, "description": {"description": "", "name": "description", "group": "Ungrouped variables", "templateType": "anything", "definition": "' from a new kind of tomato plant.'"}, "whatever": {"description": "", "name": "whatever", "group": "Ungrouped variables", "templateType": "anything", "definition": "'weights'"}, "interq": {"description": "", "name": "interq", "group": "Ungrouped variables", "templateType": "anything", "definition": "uquartile-lquartile"}, "r1": {"description": "", "name": "r1", "group": "Ungrouped variables", "templateType": "anything", "definition": "sort(r0)"}, "things": {"description": "", "name": "things", "group": "Ungrouped variables", "templateType": "anything", "definition": "'tomatoes '"}, "u": {"description": "", "name": "u", "group": "Ungrouped variables", "templateType": "anything", "definition": "random(20..60)"}, "median": {"description": "", "name": "median", "group": "Ungrouped variables", "templateType": "anything", "definition": "0.5*(r1[11]+r1[12])"}, "uquartile": {"description": "", "name": "uquartile", "group": "Ungrouped variables", "templateType": "anything", "definition": "0.25*r1[17]+0.75*r1[18]"}}, "tags": [], "preamble": {"js": "", "css": ""}, "variablesTest": {"condition": "", "maxRuns": 100}, "parts": [{"gaps": [{"correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFractionHint": true, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "minValue": "{precround(mean(r0),1)}", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "useCustomName": false, "unitTests": [], "marks": 0.5, "type": "numberentry", "scripts": {}, "customName": "", "customMarkingAlgorithm": "", "maxValue": "{precround(mean(r0),1)}", "extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "showCorrectAnswer": true, "mustBeReducedPC": 0}, {"correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFractionHint": true, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "minValue": "{siground(stdev(r0,true),3)}", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "useCustomName": false, "unitTests": [], "marks": 0.5, "type": "numberentry", "scripts": {}, "customName": "", "customMarkingAlgorithm": "", "maxValue": "{siground(stdev(r0,true),3)}", "extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "showCorrectAnswer": true, "mustBeReducedPC": 0}, {"correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFractionHint": true, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "minValue": "{median}", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "useCustomName": false, "unitTests": [], "marks": 0.5, "type": "numberentry", "scripts": {}, "customName": "", "customMarkingAlgorithm": "", "maxValue": "{median}", "extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "showCorrectAnswer": true, "mustBeReducedPC": 0}, {"correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFractionHint": true, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "minValue": "{interq}", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "useCustomName": false, "unitTests": [], "marks": 0.5, "type": "numberentry", "scripts": {}, "customName": "", "customMarkingAlgorithm": "", "maxValue": "{interq}", "extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "showCorrectAnswer": true, "mustBeReducedPC": 0}], "variableReplacementStrategy": "originalfirst", "customName": "", "variableReplacements": [], "showFeedbackIcon": true, "useCustomName": false, "unitTests": [], "marks": 0, "sortAnswers": false, "type": "gapfill", "scripts": {}, "customMarkingAlgorithm": "", "prompt": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Mean (1 dp)SD (3 sf)Median (exact value)IQR (exact value)
[[0]][[1]][[2]][[3]]
", "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true}], "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} \\]

", "statement": "

Find the mean, SD, median and IQR for the following sample of $\\var{n}$ data values:

\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
{r0[0]}{r0[1]}{r0[2]}{r0[3]}{r0[4]}{r0[5]}{r0[6]}{r0[7]}{r0[8]}{r0[9]}{r0[10]}{r0[11]}
{r0[12]}{r0[13]}{r0[14]}{r0[15]}{r0[16]}{r0[17]}{r0[18]}{r0[19]}{r0[20]}{r0[21]}{r0[22]}{r0[23]}
\n

", "ungrouped_variables": ["uquartile", "r0", "description", "things", "median", "interq", "whatever", "l", "var", "lquartile", "u", "mean", "stdev", "units", "n", "r1"], "metadata": {"description": "

Find mean, SD, median and IQR for a sample.

", "licence": "Creative Commons Attribution 4.0 International"}, "name": "Leonardo's copy of Mean, SD, median and IQR", "extensions": ["stats"], "contributors": [{"name": "Mario Orsi", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/427/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Leonardo Juliano", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3600/"}]}]}], "contributors": [{"name": "Mario Orsi", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/427/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Leonardo Juliano", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3600/"}]}