// Numbas version: exam_results_page_options {"name": "SA9 Calculate Median from a list", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "SA9 Calculate Median from a list", "tags": ["mean", "measures of average and spread", "median", "mode", "range", "taxonomy"], "metadata": {"description": "

This question provides a list of data to the student. They are asked to find the \"median\".

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

A random sample of 20 residents from Newcastle were asked about the number of times they went to see a play at the theatre last year.

\n

Here is the list of their answers:

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

", "advice": "

The median is the middle value. We need to sort the list in order:

\n

\\[ \\var{a_s[0]}, \\quad \\var{a_s[1]}, \\quad \\var{a_s[2]}, \\quad \\var{a_s[3]}, \\quad \\var{a_s[4]}, \\quad \\var{a_s[5]}, \\quad \\var{a_s[6]}, \\quad \\var{a_s[7]}, \\quad \\var{a_s[8]}, \\quad \\var{a_s[9]}, \\quad \\var{a_s[10]}, \\quad \\var{a_s[11]}, \\quad \\var{a_s[12]}, \\quad \\var{a_s[13]}, \\quad \\var{a_s[14]}, \\quad \\var{a_s[15]}, \\quad \\var{a_s[16]}, \\quad \\var{a_s[17]}, \\quad \\var{a_s[18]}, \\quad \\var{a_s[19]} \\]

\n

There is an even number of responses, so there are two numbers in the middle (10th and 11th place). To find the median, we need to find the mean of these two numbers $\\var{a_s[9]}$ and $\\var{a_s[10]}$:

\n

\\begin{align}
\\frac{\\var{a_s[9]} + \\var{a_s[10]}}{2} &=  \\frac{\\var{a_s[9] + a_s[10]}}{2} \\\\
&= \\var{median} \\text{.} 
\\end{align}

\n

 

\n

Use this link to find some resources which will help you revise this topic.

", "rulesets": {}, "extensions": ["stats"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"a2": {"name": "a2", "group": "Ungrouped variables", "definition": "repeat(random(0..8), 20)", "description": "

Option 2 for the list. Only used if there is only one mode and option 1 was not used.

", "templateType": "anything", "can_override": false}, "modea1": {"name": "modea1", "group": "Ungrouped variables", "definition": "mode(a1)", "description": "", "templateType": "anything", "can_override": false}, "median": {"name": "median", "group": "final list", "definition": "median(a)", "description": "", "templateType": "anything", "can_override": false}, "a1": {"name": "a1", "group": "Ungrouped variables", "definition": "repeat(random(0..8), 20)", "description": "

Option 1 for the list. Only used if there is only one mode.

", "templateType": "anything", "can_override": false}, "a_s": {"name": "a_s", "group": "final list", "definition": "sort(a)", "description": "

Sorted list.

", "templateType": "anything", "can_override": false}, "modea2": {"name": "modea2", "group": "Ungrouped variables", "definition": "mode(a2)", "description": "", "templateType": "anything", "can_override": false}, "a3": {"name": "a3", "group": "Ungrouped variables", "definition": "shuffle([ random(0..1),\n 2, \n random(4..6),\n random(0..3 except 2), \n random(0..3 except 2),\n random(4..6),\n 2,\n 2,\n random(4..6),\n random(7..8),\n random(0..3 except 2 except 1), \n random(4..6),\n 2,\n random(1..3 except 2), \n random(7..8),\n 2,\n random(7..8),\n random(4..6), \n random(0..3 except 2), \n 2\n])", "description": "

Option 3 for the list. Ensures there is only one mode (2) while still randomising the data.

", "templateType": "anything", "can_override": false}, "mean": {"name": "mean", "group": "final list", "definition": "mean(a)", "description": "", "templateType": "anything", "can_override": false}, "modetimes": {"name": "modetimes", "group": "final list", "definition": "map(\nlen(filter(x=j,x,a)),\nj, 0..8)", "description": "

The vector of number of times of each value in the data.

", "templateType": "anything", "can_override": false}, "range": {"name": "range", "group": "final list", "definition": "max(a) - min(a)", "description": "", "templateType": "anything", "can_override": false}, "mode1": {"name": "mode1", "group": "final list", "definition": "mode[0]", "description": "

Mode as a value.

", "templateType": "anything", "can_override": false}, "mode": {"name": "mode", "group": "final list", "definition": "mode(a)", "description": "

Mode as a vector.

", "templateType": "anything", "can_override": false}, "a": {"name": "a", "group": "final list", "definition": "if(len(modea1) = 1, a1, if(len(modea2) = 1, a2, a3))", "description": "

The final list.

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["modea1", "modea2", "a1", "a2", "a3"], "variable_groups": [{"name": "final list", "variables": ["a", "a_s", "mean", "median", "mode", "mode1", "range", "modetimes"]}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"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, "prompt": "

Find the median.

", "minValue": "median", "maxValue": "median", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}, {"name": "Lauren Desoysa", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/21504/"}, {"name": "Will Morgan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/21933/"}, {"name": "Upuli Wickramaarachchi", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/23527/"}, {"name": "Michael Pan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/23528/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}, {"name": "Lauren Desoysa", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/21504/"}, {"name": "Will Morgan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/21933/"}, {"name": "Upuli Wickramaarachchi", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/23527/"}, {"name": "Michael Pan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/23528/"}]}