// Numbas version: finer_feedback_settings {"name": "Ioannis's copy of Calculate the measures of central tendency for a sample", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variables": {"modea2": {"group": "Ungrouped variables", "definition": "mode(a2)", "name": "modea2", "templateType": "anything", "description": ""}, "a2": {"group": "Ungrouped variables", "definition": "repeat(random(0..8), 20)", "name": "a2", "templateType": "anything", "description": "

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

"}, "a1": {"group": "Ungrouped variables", "definition": "repeat(random(0..8), 20)", "name": "a1", "templateType": "anything", "description": "

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

"}, "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])", "name": "a3", "templateType": "anything", "description": "

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

"}, "mode1": {"group": "final list", "definition": "mode[0]", "name": "mode1", "templateType": "anything", "description": "

Mode as a value.

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

Mode as a vector.

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

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

"}, "range": {"group": "final list", "definition": "max(a) - min(a)", "name": "range", "templateType": "anything", "description": ""}, "a_s": {"group": "final list", "definition": "sort(a)", "name": "a_s", "templateType": "anything", "description": ""}, "mean": {"group": "final list", "definition": "mean(a)", "name": "mean", "templateType": "anything", "description": ""}, "median": {"group": "final list", "definition": "median(a)", "name": "median", "templateType": "anything", "description": ""}, "modea1": {"group": "Ungrouped variables", "definition": "mode(a1)", "name": "modea1", "templateType": "anything", "description": ""}, "a": {"group": "final list", "definition": "if(len(modea1) = 1, a1, if(len(modea2) = 1, a2, a3))", "name": "a", "templateType": "anything", "description": "

The final list.

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

a)

\n

The mean is the sum of all the responses ($\\sum x$) divided by the number of responses ($n$).

\n

Here, $n = 20$.

\n

\\begin{align}
\\sum x &= \\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]} \\\\
&= \\var{sum(a)} \\text{.}
\\end{align}

\n

Therefore we calculate the mean

\n

\\begin{align}
\\overline{x} &= \\frac{\\sum x}{n} \\\\[0.5em]
&= \\frac{\\var{sum(a)}}{20} \\\\[0.5em]
&= \\var{mean} \\text{.}
\\end{align}

\n

 

\n

b)

\n

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]} \\]

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]}$:

\\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}

 
c)

The mode is the value that occurs the most often in the data.

To find a mode, we can look at our sorted list:

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

We notice that $\\var{mode1}$ occurs the most ($\\var{modetimes[mode1]}$ times) so $\\var{mode1}$ is the mode.

\n

\n

d)

\n

Range is the difference between the highest and the lowest value in the data.

\n

To find this, we subtract the lowest value from the highest value:

\n

\\[ \\var{max(a)} - \\var{min(a)} = \\var{range} \\text{.}\\]

\n

\n

For more reading in Averages, please visit our Statistics section in the Maths Study Skills page on Moodle, and look for Averages.

\n

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

This question provides a list of data to the student. They are asked to find the mean, median, mode and range.

"}, "tags": [], "functions": {}, "statement": "

A random sample of 20 residents from London 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]}$
", "preamble": {"css": "", "js": ""}, "parts": [{"customMarkingAlgorithm": "", "prompt": "

Find the mean.

", "variableReplacements": [], "marks": "0.5", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "scripts": {}, "showCorrectAnswer": true, "allowFractions": false, "minValue": "mean", "adaptiveMarkingPenalty": 0, "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "extendBaseMarkingAlgorithm": true, "showFractionHint": true, "showFeedbackIcon": true, "mustBeReduced": false, "maxValue": "mean", "type": "numberentry", "correctAnswerStyle": "plain", "unitTests": [], "customName": "", "mustBeReducedPC": 0}, {"customMarkingAlgorithm": "", "prompt": "

Find the median.

", "variableReplacements": [], "marks": "0.5", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "scripts": {}, "showCorrectAnswer": true, "allowFractions": false, "minValue": "median", "adaptiveMarkingPenalty": 0, "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "extendBaseMarkingAlgorithm": true, "showFractionHint": true, "showFeedbackIcon": true, "mustBeReduced": false, "maxValue": "median", "type": "numberentry", "correctAnswerStyle": "plain", "unitTests": [], "customName": "", "mustBeReducedPC": 0}, {"customMarkingAlgorithm": "", "prompt": "

Find the mode.

", "variableReplacements": [], "marks": "0.5", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "scripts": {}, "showCorrectAnswer": true, "allowFractions": false, "minValue": "mode1", "adaptiveMarkingPenalty": 0, "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "extendBaseMarkingAlgorithm": true, "showFractionHint": true, "showFeedbackIcon": true, "mustBeReduced": false, "maxValue": "mode1", "type": "numberentry", "correctAnswerStyle": "plain", "unitTests": [], "customName": "", "mustBeReducedPC": 0}, {"customMarkingAlgorithm": "", "prompt": "

Find the range.

", "variableReplacements": [], "marks": "0.5", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "scripts": {}, "showCorrectAnswer": true, "allowFractions": false, "minValue": "range", "adaptiveMarkingPenalty": 0, "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "extendBaseMarkingAlgorithm": true, "showFractionHint": true, "showFeedbackIcon": true, "mustBeReduced": false, "maxValue": "range", "type": "numberentry", "correctAnswerStyle": "plain", "unitTests": [], "customName": "", "mustBeReducedPC": 0}], "name": "Ioannis's copy of Calculate the measures of central tendency for a sample", "variable_groups": [{"variables": ["a", "mean", "median", "mode", "mode1", "range", "modetimes", "a_s"], "name": "final list"}], "ungrouped_variables": ["modea1", "modea2", "a1", "a2", "a3"], "rulesets": {}, "extensions": ["stats"], "type": "question", "contributors": [{"name": "Ioannis Lignos", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/757/"}]}]}], "contributors": [{"name": "Ioannis Lignos", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/757/"}]}