// Numbas version: finer_feedback_settings {"name": "Measures of central tendency from frequency tables", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "

The total number of goals scored during a random sample of $30$ Premier League football matches are shown below:

\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{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{a[20]}$$\\var{a[21]}$$\\var{a[22]}$$\\var{a[23]}$$\\var{a[24]}$$\\var{a[25]}$$\\var{a[26]}$$\\var{a[27]}$$\\var{a[28]}$$\\var{a[29]}$
\n

", "variables": {"modea3": {"templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "mode(a3)", "name": "modea3"}, "modea2": {"templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "mode(a2)", "name": "modea2"}, "a3": {"templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "shuffle(repeat(0, 7) + repeat(1, 10) + repeat(2, 5) + repeat(3, 4) + repeat(4, 2) + repeat(5,1) + repeat(6,1))", "name": "a3"}, "mode": {"templateType": "anything", "description": "", "group": "Final data", "definition": "m[0]", "name": "mode"}, "a1": {"templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "shuffle(repeat(random(0..1), 13) + 0 + 2 + 2 + repeat(random(2..3), 10) + repeat(random(4..5), 3) + random(0..6))", "name": "a1"}, "freq": {"templateType": "anything", "description": "", "group": "Final data", "definition": "map(\nlen(filter(x=j,x,a)),\nj, 0..6)", "name": "freq"}, "median": {"templateType": "anything", "description": "", "group": "Final data", "definition": "median(a)", "name": "median"}, "a2": {"templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "shuffle(repeat(random(0..1), 13) + 0 + 2 + 2 + repeat(random(2..3), 10) + repeat(random(4..5), 3) + random(0..6))", "name": "a2"}, "mean": {"templateType": "anything", "description": "", "group": "Final data", "definition": "mean(a)", "name": "mean"}, "as": {"templateType": "anything", "description": "", "group": "Final data", "definition": "sort(a)", "name": "as"}, "a": {"templateType": "anything", "description": "", "group": "Final data", "definition": "if(len(modea1) = 1, a1, if(len(modea2) = 1, a2, a3))", "name": "a"}, "m": {"templateType": "anything", "description": "", "group": "Final data", "definition": "mode(a)", "name": "m"}, "modea1": {"templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "mode(a1)", "name": "modea1"}}, "tags": [], "extensions": ["stats"], "name": "Measures of central tendency from frequency tables", "metadata": {"description": "

Given a table of data, calculate the mean, mode and median, and complete a frequency table.

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

a)

\n

Organising the data in a frequency table helps to make mistakes less likely when calculating statistics from our data, summarising the responses all in one place with fewer numbers.

\n

Each row of the frequency column gives the number of Premier League football matches with the corresponding number of goals.

\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
Total number of goals scoredFrequency
$0$$\\var{freq[0]}$
$1$$\\var{freq[1]}$
$2$$\\var{freq[2]}$
$3$$\\var{freq[3]}$
$4$$\\var{freq[4]}$
$5$$\\var{freq[5]}$
$6$$\\var{freq[6]}$
Total$30$
\n

Always remember to check whether your frequency column adds up to the total (here, it is $30$) to make sure you have not left out any responses.

\n

b)

\n

Mean

\n

The mean number of goals is the total number of goals, $\\sum x$, divided by the number of football matches in the sample, $n$.

\n

\\begin{align}  
\\sum x &= 0 \\times \\var{freq[0]} + 1 \\times \\var{freq[1]} + 2 \\times \\var{freq[2]} + 3 \\times \\var{freq[3]} + 4 \\times \\var{freq[4]} + 5 \\times \\var{freq[5]} + 6 \\times \\var{freq[6]}
\\\\
&= 0 + \\var{1*freq[1]} + \\var{2*freq[2]} + \\var{3*freq[3]} + \\var{4*freq[4]} + \\var{5*freq[5]} + \\var{6*freq[6]} \\\\&= \\var{sum(a)} \\text{.}
\\end{align}

\n

The total number of football matches $n$ is $30$.

\n

Therefore the mean is

\n

\\begin{align}
\\bar{x} &= \\frac{\\sum x}{n} \\\\
&= \\frac{\\var{sum(a)}}{30} \\\\
&= \\var{precround(mean, 2)} \\text{.}
\\end{align}

\n

\n

Mode

\n

The mode is the value with the highest frequency. Here, the mode is $\\var{mode}$ goals, with frequency $\\var{freq[mode]}$.

\n

Median

\n

The median is the \"middle\" value in the sample, when arranged in ascending order.

\n

To find the middle position within a data set, we take the sample size, add $1$, then divide by $2$. For our data set, the middle position is

\n

$\\displaystyle\\frac{n+1}{2}=\\frac{30+1}{2}=15.5.$

\n

As there is not actually a $15.5$th position, we need to find the mean of the $15$th and $16$th values. We can count from the top of the table until we locate rows where these values lie, as the numbers in the table are already sorted by order.

\n

Here, both $15$th and $16$th value lie in the row $\\var{as[14]}$.Here, the $15$th value lies in the row $\\var{as[14]}$ while the $16$th value lies in the row $\\var{as[15]}$.

\n

As $15$th value $= 16$th value $= \\var{as[14]}$, the median is $\\var{as[14]}$. The $15$th value $= \\var{as[14]}$ and $16$th value $= \\var{as[15]}$ and their mean is given by

\n

$ \\displaystyle \\frac{\\var{as[14]} + \\var{as[15]}}{2} =  \\frac{\\var{as[14] + as[15]}}{2} = \\var{median}{.}$

\n

This is the median for this data.

\n

", "rulesets": {}, "variablesTest": {"condition": "", "maxRuns": "1000"}, "preamble": {"js": "", "css": ""}, "ungrouped_variables": ["a1", "modea1", "a2", "modea2", "a3", "modea3"], "parts": [{"extendBaseMarkingAlgorithm": true, "gaps": [{"extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "customMarkingAlgorithm": "", "correctAnswerFraction": false, "scripts": {}, "marks": 1, "unitTests": [], "variableReplacements": [], "maxValue": "freq[0]", "correctAnswerStyle": "plain", "minValue": "freq[0]"}, {"extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "customMarkingAlgorithm": "", "correctAnswerFraction": false, "scripts": {}, "marks": 1, "unitTests": [], "variableReplacements": [], "maxValue": "freq[1]", "correctAnswerStyle": "plain", "minValue": "freq[1]"}, {"extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "customMarkingAlgorithm": "", "correctAnswerFraction": false, "scripts": {}, "marks": 1, "unitTests": [], "variableReplacements": [], "maxValue": "freq[2]", "correctAnswerStyle": "plain", "minValue": "freq[2]"}, {"extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "customMarkingAlgorithm": "", "correctAnswerFraction": false, "scripts": {}, "marks": 1, "unitTests": [], "variableReplacements": [], "maxValue": "freq[3]", "correctAnswerStyle": "plain", "minValue": "freq[3]"}, {"extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "customMarkingAlgorithm": "", "correctAnswerFraction": false, "scripts": {}, "marks": 1, "unitTests": [], "variableReplacements": [], "maxValue": "freq[4]", "correctAnswerStyle": "plain", "minValue": "freq[4]"}, {"extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "customMarkingAlgorithm": "", "correctAnswerFraction": false, "scripts": {}, "marks": 1, "unitTests": [], "variableReplacements": [], "maxValue": "freq[5]", "correctAnswerStyle": "plain", "minValue": "freq[5]"}, {"extendBaseMarkingAlgorithm": true, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "customMarkingAlgorithm": "", "correctAnswerFraction": false, "scripts": {}, "marks": 1, "unitTests": [], "variableReplacements": [], "maxValue": "freq[6]", "correctAnswerStyle": "plain", "minValue": "freq[6]"}], "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "gapfill", "customMarkingAlgorithm": "", "scripts": {}, "marks": 0, "unitTests": [], "variableReplacements": [], "prompt": "

Complete the following frequency 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
Number goals scoredFrequency
$0$[[0]]
$1$[[1]]
$2$[[2]]
$3$[[3]]
$4$[[4]]
$5$[[5]]
$6$[[6]]
Total$30$
\n

", "sortAnswers": false}, {"extendBaseMarkingAlgorithm": true, "gaps": [{"allowFractions": false, "mustBeReducedPC": 0, "minValue": "mean", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "precisionPartialCredit": 0, "marks": 1, "precision": "2", "strictPrecision": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "showFeedbackIcon": true, "correctAnswerFraction": false, "maxValue": "mean", "type": "numberentry", "customMarkingAlgorithm": "", "scripts": {}, "extendBaseMarkingAlgorithm": true, "unitTests": [], "variableReplacements": [], "precisionType": "dp", "showPrecisionHint": true, "precisionMessage": "You have not given your answer to the correct precision."}, {"allowFractions": false, "mustBeReducedPC": 0, "minValue": "mode", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "precisionPartialCredit": 0, "marks": 1, "precision": "2", "strictPrecision": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "showFeedbackIcon": true, "correctAnswerFraction": false, "maxValue": "mode", "type": "numberentry", "customMarkingAlgorithm": "", "scripts": {}, "extendBaseMarkingAlgorithm": true, "unitTests": [], "variableReplacements": [], "precisionType": "dp", "showPrecisionHint": true, "precisionMessage": "You have not given your answer to the correct precision."}, {"allowFractions": false, "mustBeReducedPC": 0, "minValue": "median", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "precisionPartialCredit": 0, "marks": 1, "precision": "2", "strictPrecision": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "showFeedbackIcon": true, "correctAnswerFraction": false, "maxValue": "median", "type": "numberentry", "customMarkingAlgorithm": "", "scripts": {}, "extendBaseMarkingAlgorithm": true, "unitTests": [], "variableReplacements": [], "precisionType": "dp", "showPrecisionHint": true, "precisionMessage": "You have not given your answer to the correct precision."}], "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "gapfill", "customMarkingAlgorithm": "", "scripts": {}, "marks": 0, "unitTests": [], "variableReplacements": [], "prompt": "

Find the mean, mode and median for this data.

\n

Mean = [[0]]

\n

Mode =  [[1]]

\n

Median =  [[2]]

", "sortAnswers": false}], "variable_groups": [{"variables": ["a", "mean", "median", "m", "mode", "freq", "as"], "name": "Final data"}], "functions": {}, "type": "question", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Vicky Hall", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/659/"}, {"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}, {"name": "Lauren Frances Desoysa", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2490/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Vicky Hall", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/659/"}, {"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}, {"name": "Lauren Frances Desoysa", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2490/"}]}