// Numbas version: finer_feedback_settings {"metadata": {"description": "
Calculate and work with measures of central tendency such as mean, median and mode, and measures of spread such as range and standard deviation.
", "licence": "Creative Commons Attribution 4.0 International"}, "timing": {"timedwarning": {"action": "none", "message": ""}, "allowPause": false, "timeout": {"action": "none", "message": ""}}, "name": "Calculate measures of central tendency and spread", "duration": 3000, "navigation": {"onleave": {"action": "none", "message": ""}, "preventleave": true, "showfrontpage": true, "showresultspage": "oncompletion", "allowregen": true, "browse": true, "reverse": true}, "showQuestionGroupNames": false, "percentPass": 0, "showstudentname": true, "question_groups": [{"name": "Group", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questions": [{"name": "Calculate the measures of central tendency for a sample", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "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/"}], "variable_groups": [{"variables": ["a", "a_s", "mean", "median", "mode", "mode1", "range", "modetimes"], "name": "final list"}], "preamble": {"js": "", "css": ""}, "parts": [{"correctAnswerFraction": false, "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "allowFractions": false, "minValue": "mean", "maxValue": "mean", "showFractionHint": true, "variableReplacements": [], "useCustomName": false, "customName": "", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "scripts": {}, "marks": 1, "prompt": "Find the mean.
"}, {"correctAnswerFraction": false, "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "allowFractions": false, "minValue": "median", "maxValue": "median", "showFractionHint": true, "variableReplacements": [], "useCustomName": false, "customName": "", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "scripts": {}, "marks": 1, "prompt": "Find the median.
"}, {"correctAnswerFraction": false, "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "allowFractions": false, "minValue": "mode1", "maxValue": "mode1", "showFractionHint": true, "variableReplacements": [], "useCustomName": false, "customName": "", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "scripts": {}, "marks": 1, "prompt": "Find the mode.
"}, {"correctAnswerFraction": false, "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "allowFractions": false, "minValue": "range", "maxValue": "range", "showFractionHint": true, "variableReplacements": [], "useCustomName": false, "customName": "", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "scripts": {}, "marks": 1, "prompt": "Find the range.
"}], "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": ["mean", "measures of average and spread", "median", "mode", "range", "taxonomy"], "variables": {"a2": {"templateType": "anything", "description": "Option 2 for the list. Only used if there is only one mode and option 1 was not used.
", "definition": "repeat(random(0..8), 20)", "name": "a2", "group": "Ungrouped variables"}, "modea1": {"templateType": "anything", "description": "", "definition": "mode(a1)", "name": "modea1", "group": "Ungrouped variables"}, "median": {"templateType": "anything", "description": "", "definition": "median(a)", "name": "median", "group": "final list"}, "a1": {"templateType": "anything", "description": "Option 1 for the list. Only used if there is only one mode.
", "definition": "repeat(random(0..8), 20)", "name": "a1", "group": "Ungrouped variables"}, "a_s": {"templateType": "anything", "description": "Sorted list.
", "definition": "sort(a)", "name": "a_s", "group": "final list"}, "modea2": {"templateType": "anything", "description": "", "definition": "mode(a2)", "name": "modea2", "group": "Ungrouped variables"}, "a3": {"templateType": "anything", "description": "Option 3 for the list. Ensures there is only one mode (2) while still randomising the data.
", "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", "group": "Ungrouped variables"}, "mean": {"templateType": "anything", "description": "", "definition": "mean(a)", "name": "mean", "group": "final list"}, "modetimes": {"templateType": "anything", "description": "The vector of number of times of each value in the data.
", "definition": "map(\nlen(filter(x=j,x,a)),\nj, 0..8)", "name": "modetimes", "group": "final list"}, "range": {"templateType": "anything", "description": "", "definition": "max(a) - min(a)", "name": "range", "group": "final list"}, "mode1": {"templateType": "anything", "description": "Mode as a value.
", "definition": "mode[0]", "name": "mode1", "group": "final list"}, "mode": {"templateType": "anything", "description": "Mode as a vector.
", "definition": "mode(a)", "name": "mode", "group": "final list"}, "a": {"templateType": "anything", "description": "The final list.
", "definition": "if(len(modea1) = 1, a1, if(len(modea2) = 1, a2, a3))", "name": "a", "group": "final list"}}, "rulesets": {}, "functions": {}, "ungrouped_variables": ["modea1", "modea2", "a1", "a2", "a3"], "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.
\nHere is the list of their answers:
\n$\\var{a[0]}$ | \n$\\var{a[1]}$ | \n$\\var{a[2]}$ | \n$\\var{a[3]}$ | \n$\\var{a[4]}$ | \n$\\var{a[5]}$ | \n$\\var{a[6]}$ | \n$\\var{a[7]}$ | \n$\\var{a[8]}$ | \n$\\var{a[9]}$ | \n
$\\var{a[10]}$ | \n$\\var{a[11]}$ | \n$\\var{a[12]}$ | \n$\\var{a[13]}$ | \n$\\var{a[14]}$ | \n$\\var{a[15]}$ | \n$\\var{a[16]}$ | \n$\\var{a[17]}$ | \n$\\var{a[18]}$ | \n$\\var{a[19]}$ | \n
The mean is the sum of all the responses ($\\sum x$) divided by the number of responses ($n$).
\nHere, $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}
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
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]} \\]
\nThere 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
The mode is the value that occurs the most often in the data.
\nTo find a mode, we can look at our sorted list:
\n$\\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]}$.
\nWe notice that $\\var{mode1}$ occurs the most ($\\var{modetimes[mode1]}$ times) so $\\var{mode1}$ is the mode.
\n\n
Range is the difference between the highest and the lowest value in the data.
\nTo find this, we subtract the lowest value from the highest value:
\n\\[ \\var{max(a)} - \\var{min(a)} = \\var{range} \\text{.}\\]
", "variablesTest": {"condition": "", "maxRuns": 100}, "type": "question"}, {"name": "Estimate the mean and find the modal class for grouped data", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}], "metadata": {"description": "Fill in a frequency table for grouped data, then estimate the mean and identify the modal class.
", "licence": "Creative Commons Attribution 4.0 International"}, "rulesets": {}, "type": "question", "ungrouped_variables": ["freq", "freq_midpoint", "sixty", "seventy"], "advice": "We calculate the midpoint by finding the mean of the lower and upper bounds. For example, the midpoint for $40 \\leq a \\lt 50$ is
\n\\[\\begin{align} \\displaystyle \\frac{40 + 50}{2} &= \\frac{90}{2} \\\\&= 45 \\text{.} \\end{align}\\]
\nTo calculate the final column, we multiply the second and the third columns:
\n\\[\\var{freq[4]} \\times 45 = \\var{45*freq[4]} \\text{.} \\]
\nFinally, when we have completed all the other values, we can calculate the total for the last column.
\n\\[\\begin{align} \\text{Total} &= 5\\times\\var{freq[0]} + 15\\times\\var{freq[1]} + 25\\times\\var{freq[2]} + 35\\times\\var{freq[3]} + 45\\times\\var{freq[4]} + 55\\times\\var{freq[5]} + 65\\times\\var{freq[6]} + 75\\times\\var{freq[7]} + 85\\times\\var{freq[8]} + 95\\times\\var{freq[9]} \\\\&= \\var{5*freq[0]} + \\var{15*freq[1]} + \\var{25*freq[2]} + \\var{35*freq[3]} + \\var{45*freq[4]} + \\var{55*freq[5]} + \\var{65*freq[6]} + \\var{75*freq[7]} + \\var{85*freq[8]} + \\var{95*freq[9]} \\\\&= \\var{freq_midpoint} \\text{.} \\end{align}\\]
\nThe completed frequency table looks like this:
\nStage 1 grade $a$ | \nFrequency | \nMidpoint | \nFrequency $\\times$ Midpoint | \n
---|---|---|---|
$0 \\leq a \\lt 10$ | \n$\\var{freq[0]}$ | \n$5$ | \n$\\var{5*freq[0]}$ | \n
$10 \\leq a \\lt 20$ | \n$\\var{freq[1]}$ | \n$15$ | \n$\\var{15*freq[1]}$ | \n
$20 \\leq a \\lt 30$ | \n$\\var{freq[2]}$ | \n$25$ | \n$\\var{25*freq[2]}$ | \n
$30 \\leq a \\lt 40$ | \n$\\var{freq[3]}$ | \n$35$ | \n$\\var{35*freq[3]}$ | \n
$40 \\leq a \\lt 50$ | \n$\\var{freq[4]}$ | \n$45$ | \n$\\var{45*freq[4]}$ | \n
$50 \\leq a \\lt 60$ | \n$\\var{freq[5]}$ | \n$55$ | \n$\\var{55*freq[5]}$ | \n
$60 \\leq a \\lt 70$ | \n$\\var{freq[6]}$ | \n$65$ | \n$\\var{65*freq[6]}$ | \n
$70 \\leq a \\lt 80$ | \n$\\var{freq[7]}$ | \n$75$ | \n$\\var{75*freq[7]}$ | \n
$80 \\leq a \\lt 90$ | \n$\\var{freq[8]}$ | \n$85$ | \n$\\var{85*freq[8]}$ | \n
$90 \\leq a \\lt 100$ | \n$\\var{freq[9]}$ | \n$95$ | \n$\\var{95*freq[9]}$ | \n
Totals | \n$\\var{sum(freq)}$ | \n\n | $\\var{freq_midpoint}$ | \n
\n
We don't know exactly how much each student got, so we have to assume all students got the midpoint of their group. To estimate the sum of all student grades in a particular interval, we can multiply the interval's midpoint by its frequency.
\nThe sum of all the grades in the class is the sum of the estimates for each interval. We've already calculated this in the table above.
\nSo the estimate for the mean, $\\bar{a}$, is as follows:
\n\\begin{align}
\\bar{a} &\\approx \\frac{\\var{freq_midpoint}}{\\var{sum(freq)}} \\\\
&= \\var{freq_midpoint/sum(freq)} \\text{.}
\\end{align}
Rounding the mean to 2 decimal places, we get $\\var{precround(freq_midpoint/sum(freq),2)}$.
\nThe modal class is the interval with the highest frequency. In this case, the interval $50 \\leq a \\lt 60$ is the modal class.
", "variable_groups": [], "statement": "$\\var{sum(freq)}$ Mathematics and Statistics students have finished their first year at Newcastle University.
", "parts": [{"scripts": {}, "variableReplacementStrategy": "originalfirst", "type": "gapfill", "stepsPenalty": 0, "steps": [{"scripts": {}, "variableReplacementStrategy": "originalfirst", "type": "information", "showCorrectAnswer": true, "prompt": "The midpoint of an interval is the mean of the upper and lower bounds.
", "variableReplacements": [], "showFeedbackIcon": true, "marks": 0}], "marks": 0, "variableReplacements": [], "showFeedbackIcon": true, "prompt": "Their stage 1 grades (denoted $a$) have been summarised and grouped into intervals in the frequency table below. Complete the table.
\nStage 1 grade $a$ | \nFrequency | \nMidpoint | \nFrequency $\\times$ Midpoint | \n
---|---|---|---|
$0 \\leq a \\lt 10$ | \n$\\var{freq[0]}$ | \n[[0]] | \n[[10]] | \n
$10 \\leq a \\lt 20$ | \n$\\var{freq[1]}$ | \n[[1]] | \n[[11]] | \n
$20 \\leq a \\lt 30$ | \n$\\var{freq[2]}$ | \n[[2]] | \n[[12]] | \n
$30 \\leq a \\lt 40$ | \n$\\var{freq[3]}$ | \n[[3]] | \n[[13]] | \n
$40 \\leq a \\lt 50$ | \n$\\var{freq[4]}$ | \n[[4]] | \n[[14]] | \n
$50 \\leq a \\lt 60$ | \n$\\var{freq[5]}$ | \n[[5]] | \n[[15]] | \n
$60 \\leq a \\lt 70$ | \n$\\var{freq[6]}$ | \n[[6]] | \n[[16]] | \n
$70 \\leq a \\lt 80$ | \n$\\var{freq[7]}$ | \n[[7]] | \n[[17]] | \n
$80 \\leq a \\lt 90$ | \n$\\var{freq[8]}$ | \n[[8]] | \n[[18]] | \n
$90 \\leq a \\lt 100$ | \n$\\var{freq[9]}$ | \n[[9]] | \n[[19]] | \n
Totals | \n$\\var{sum(freq)}$ | \n$-$ | \n[[20]] | \n
Now use the table to estimate the mean grade, $\\bar{a}$.
", "precision": "2", "showFeedbackIcon": true, "minValue": "freq_midpoint/sum(freq)", "scripts": {}, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "mustBeReduced": false, "precisionMessage": "You have not given your answer to the correct precision."}, {"shuffleChoices": false, "minMarks": 0, "showCorrectAnswer": true, "displayColumns": "5", "variableReplacements": [], "showFeedbackIcon": true, "prompt": "From the choices below, choose the correct modal class for this data.
", "choices": ["$30 \\leq a \\lt 40$
", "$40 \\leq a \\lt 50$
", "$50 \\leq a \\lt 60$
", "$60 \\leq a \\lt 70$
", "$70 \\leq a \\lt 80$
"], "scripts": {}, "variableReplacementStrategy": "originalfirst", "type": "1_n_2", "maxMarks": 0, "marks": 0, "distractors": ["", "", "", "", ""], "matrix": [0, 0, "2", "0", 0], "displayType": "radiogroup"}], "tags": ["estimate the mean", "grouped data", "intervals", "modal class", "taxonomy"], "preamble": {"css": "", "js": ""}, "functions": {}, "variables": {"seventy": {"description": "", "group": "Ungrouped variables", "definition": "random(35..sixty except sixty)", "name": "seventy", "templateType": "anything"}, "freq_midpoint": {"description": "", "group": "Ungrouped variables", "definition": "5*freq[0] + 15*freq[1] + 25*freq[2] + 35*freq[3] + 45*freq[4] + 55*freq[5] + 65*freq[6] + 75*freq[7] + 85*freq[8] + 95*freq[9]", "name": "freq_midpoint", "templateType": "anything"}, "freq": {"description": "$0 \\leq a \\lt 10$ | \n0..8 | \n\n | \n |
$10 \\leq a \\lt 20$ | \n0..7 | \n\n | \n |
$20 \\leq a \\lt 30$ | \n0..4 | \n\n | \n |
$30 \\leq a \\lt 40$ | \n6..18 | \n\n | \n |
$40 \\leq a \\lt 50$ | \n20..50 | \n\n | \n |
$50 \\leq a \\lt 60$ | \n30..60 | \n\n\n\n | \n\n |
60 70 | \n\n | \n | \n |
$70 \\leq a \\lt 80$ | \n10..40 | \n\n | \n |
$80 \\leq a \\lt 90$ | \n0..6 | \n\n | \n |
$90 \\leq a \\lt 100$ | \n0..1 | \n\n | \n |
Given a table of data, calculate the mean, mode and median, and complete a frequency table.
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "30 random students were asked about the number of siblings they have. These are their responses:
\n$\\var{a[0]}$ | \n$\\var{a[1]}$ | \n$\\var{a[2]}$ | \n$\\var{a[3]}$ | \n$\\var{a[4]}$ | \n$\\var{a[5]}$ | \n$\\var{a[6]}$ | \n$\\var{a[7]}$ | \n$\\var{a[8]}$ | \n$\\var{a[9]}$ | \n
$\\var{a[10]}$ | \n$\\var{a[11]}$ | \n$\\var{a[12]}$ | \n$\\var{a[13]}$ | \n$\\var{a[14]}$ | \n$\\var{a[15]}$ | \n$\\var{a[16]}$ | \n$\\var{a[17]}$ | \n$\\var{a[18]}$ | \n$\\var{a[19]}$ | \n
$\\var{a[20]}$ | \n$\\var{a[21]}$ | \n$\\var{a[22]}$ | \n$\\var{a[23]}$ | \n$\\var{a[24]}$ | \n$\\var{a[25]}$ | \n$\\var{a[26]}$ | \n$\\var{a[27]}$ | \n$\\var{a[28]}$ | \n$\\var{a[29]}$ | \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.
\nEach row of the frequency column gives the number of students with the corresponding number of siblings.
\nNumber of siblings | \nFrequency | \n
---|---|
$0$ | \n$\\var{freq[0]}$ | \n
$1$ | \n$\\var{freq[1]}$ | \n
$2$ | \n$\\var{freq[2]}$ | \n
$3$ | \n$\\var{freq[3]}$ | \n
$4$ | \n$\\var{freq[4]}$ | \n
$5$ | \n$\\var{freq[5]}$ | \n
$6$ | \n$\\var{freq[6]}$ | \n
Total | \n$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.
\nThe mean number of siblings is the total number of siblings, $\\sum x$, divided by the number of students 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}
The total number of students $n$ is $30$.
\nTherefore the mean is
\n\\begin{align}
\\bar{x} &= \\frac{\\sum x}{n} \\\\
&= \\frac{\\var{sum(a)}}{30} \\\\
&= \\var{mean} \\text{.}
\\end{align}
Rounding the answer to 2 decimal places, we get $\\var{precround(mean, 2)}$.
\nThe mode is the value with the highest frequency. Here, the mode is $\\var{mode}$ siblings, with frequency $\\var{freq[mode]}$.
\nThe median is the \"middle\" value in the sample, when arranged in numerical order.
\nSince $n = 30$, we have two middle values in this data (15th and 16th place). We can count from the top of the table until we locate rows where these middle values lie, as the numbers in the table are already sorted by order.
\nHere, both $15$th and $16$th value lie in the row $\\var{asa[14]}$.Here, the $15$th value lies in the row $\\var{asa[14]}$ while the $16$th value lies in the row $\\var{asa[15]}$.
\nAs $15$th value $= 16$th value $= \\var{asa[14]}$, the median is $\\var{asa[14]}$.As $15$th value $= \\var{asa[14]}$ and $16$th value $= \\var{asa[15]}$, we need to find their mean.
\n\\[ \\displaystyle \\begin{align} \\frac{\\var{asa[14]} + \\var{asa[15]}}{2} &= \\frac{\\var{asa[14] + asa[15]}}{2} \\\\&= \\var{median} \\text{.} \\end{align}\\]
\nThis is the median for this data.
\n", "rulesets": {}, "variables": {"m": {"name": "m", "group": "Final data", "definition": "mode(a)", "description": "", "templateType": "anything"}, "a2": {"name": "a2", "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))", "description": "", "templateType": "anything"}, "a1": {"name": "a1", "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))", "description": "", "templateType": "anything"}, "modea1": {"name": "modea1", "group": "Ungrouped variables", "definition": "mode(a1)", "description": "", "templateType": "anything"}, "mode": {"name": "mode", "group": "Final data", "definition": "m[0]", "description": "", "templateType": "anything"}, "mean": {"name": "mean", "group": "Final data", "definition": "mean(a)", "description": "", "templateType": "anything"}, "modea2": {"name": "modea2", "group": "Ungrouped variables", "definition": "mode(a2)", "description": "", "templateType": "anything"}, "a3": {"name": "a3", "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))", "description": "", "templateType": "anything"}, "freq": {"name": "freq", "group": "Final data", "definition": "map(\nlen(filter(x=j,x,a)),\nj, 0..6)", "description": "", "templateType": "anything"}, "median": {"name": "median", "group": "Final data", "definition": "median(a)", "description": "", "templateType": "anything"}, "a": {"name": "a", "group": "Final data", "definition": "if(len(modea1) = 1, a1, if(len(modea2) = 1, a2, a3))", "description": "", "templateType": "anything"}, "modea3": {"name": "modea3", "group": "Ungrouped variables", "definition": "mode(a3)", "description": "", "templateType": "anything"}, "asa": {"name": "asa", "group": "Final data", "definition": "sort(a)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": "1000"}, "ungrouped_variables": ["a1", "modea1", "a2", "modea2", "a3", "modea3"], "variable_groups": [{"name": "Final data", "variables": ["a", "mean", "median", "m", "mode", "freq", "asa"]}], "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": "Complete the following frequency table:
\nNumber of siblings | \nFrequency | \n
---|---|
$0$ | \n[[0]] | \n
$1$ | \n[[1]] | \n
$2$ | \n[[2]] | \n
$3$ | \n[[3]] | \n
$4$ | \n[[4]] | \n
$5$ | \n[[5]] | \n
$6$ | \n[[6]] | \n
Total | \n$30$ | \n
Find the mean, mode and median for this data.
\nMean = [[0]]
\nMode = [[1]]
\nMedian = [[2]]
", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "Mean", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "mean", "maxValue": "mean", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Mode", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "mode", "maxValue": "mode", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Median", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "median", "maxValue": "median", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question"}, {"name": "Weight of a scoop in two ice cream parlours", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}], "type": "question", "tags": ["mean", "median", "mode", "range", "taxonomy"], "variablesTest": {"condition": "\n", "maxRuns": 100}, "variables": {"b6": {"templateType": "anything", "name": "b6", "description": "", "definition": "meanab - 6", "group": "B"}, "alist": {"templateType": "anything", "name": "alist", "description": "", "definition": "[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]", "group": "A"}, "a2": {"templateType": "anything", "name": "a2", "description": "", "definition": "meanab - 1 - random2", "group": "A"}, "bsort": {"templateType": "anything", "name": "bsort", "description": "", "definition": "sort(b)", "group": "B"}, "suma": {"templateType": "anything", "name": "suma", "description": "", "definition": "sum(a)", "group": "Ungrouped variables"}, "rangeb": {"templateType": "anything", "name": "rangeb", "description": "", "definition": "max(b) - min(b)", "group": "Ungrouped variables"}, "b5": {"templateType": "anything", "name": "b5", "description": "", "definition": "meanab - 8 ", "group": "B"}, "meana": {"templateType": "anything", "name": "meana", "description": "", "definition": "(a1 + a2 + a3 + a4 + a5+ a6 + a7 + a8 + a9 + a10)/10", "group": "Ungrouped variables"}, "a6": {"templateType": "anything", "name": "a6", "description": "", "definition": "meanab", "group": "A"}, "a10": {"templateType": "anything", "name": "a10", "description": "", "definition": "meanab + 2 + random2", "group": "A"}, "rangea": {"templateType": "anything", "name": "rangea", "description": "", "definition": "max(a) - min(a)", "group": "Ungrouped variables"}, "asort": {"templateType": "anything", "name": "asort", "description": "", "definition": "sort(a)", "group": "A"}, "a": {"templateType": "anything", "name": "a", "description": "", "definition": "shuffle(alist)", "group": "A"}, "modea": {"templateType": "anything", "name": "modea", "description": "", "definition": "mode(a)[0]", "group": "Ungrouped variables"}, "modeb": {"templateType": "anything", "name": "modeb", "description": "", "definition": "mode(b)[0]", "group": "Ungrouped variables"}, "b3": {"templateType": "anything", "name": "b3", "description": "", "definition": "meanab - 12", "group": "B"}, "random": {"templateType": "anything", "name": "random", "description": "", "definition": "random(2..10 #2)", "group": "B"}, "a9": {"templateType": "anything", "name": "a9", "description": "", "definition": "meanab + 1 + random2", "group": "A"}, "meanb": {"templateType": "anything", "name": "meanb", "description": "", "definition": "(b1+b2+b3+b4+b5+b6+b7+b8+b9+b10)/10", "group": "Ungrouped variables"}, "a3": {"templateType": "anything", "name": "a3", "description": "", "definition": "meanab - 2", "group": "A"}, "meanab": {"templateType": "anything", "name": "meanab", "description": "", "definition": "random(80..90)", "group": "Ungrouped variables"}, "b10": {"templateType": "anything", "name": "b10", "description": "", "definition": "meanab + 27 + random/2", "group": "B"}, "a8": {"templateType": "anything", "name": "a8", "description": "", "definition": "meanab + 1", "group": "A"}, "b1": {"templateType": "anything", "name": "b1", "description": "", "definition": "meanab - 15 - random", "group": "B"}, "b4": {"templateType": "anything", "name": "b4", "description": "", "definition": "meanab - 10", "group": "B"}, "medianb": {"templateType": "anything", "name": "medianb", "description": "", "definition": "median(b)", "group": "Ungrouped variables"}, "b7": {"templateType": "anything", "name": "b7", "description": "", "definition": "meanab - 2", "group": "B"}, "b9": {"templateType": "anything", "name": "b9", "description": "", "definition": "meanab + 27 + random/2", "group": "B"}, "a4": {"templateType": "anything", "name": "a4", "description": "", "definition": "meanab", "group": "A"}, "b8": {"templateType": "anything", "name": "b8", "description": "", "definition": "meanab + 13", "group": "B"}, "a5": {"templateType": "anything", "name": "a5", "description": "", "definition": "meanab", "group": "A"}, "random2": {"templateType": "anything", "name": "random2", "description": "", "definition": "random(1..3)", "group": "A"}, "b": {"templateType": "anything", "name": "b", "description": "", "definition": "shuffle(blist)", "group": "B"}, "b2": {"templateType": "anything", "name": "b2", "description": "", "definition": "meanab - 14", "group": "B"}, "sumb": {"templateType": "anything", "name": "sumb", "description": "", "definition": "sum(b)", "group": "Ungrouped variables"}, "a7": {"templateType": "anything", "name": "a7", "description": "", "definition": "meanab + 1", "group": "A"}, "a1": {"templateType": "anything", "name": "a1", "description": "", "definition": "meanab - 2 - random2", "group": "A"}, "mediana": {"templateType": "anything", "name": "mediana", "description": "", "definition": "median(a)", "group": "Ungrouped variables"}, "blist": {"templateType": "anything", "name": "blist", "description": "", "definition": "[b1,b2,b3,b4,b5,b6,b7,b8,b9,b10]", "group": "B"}}, "functions": {}, "statement": "Two ice cream parlours called Sweet Heaven and Tasty Hell both sell ice cream for the same price. Alice likes both of these places equally, and has visited each place 10 times. After every visit, Alice measured the weight of her scoop, in grams, to the nearest integer. Here is the table of her values:
\nSweet Heaven (g) | \n$\\var{a[0]}$ | \n$\\var{a[1]}$ | \n$\\var{a[2]}$ | \n$\\var{a[3]}$ | \n$\\var{a[4]}$ | \n$\\var{a[5]}$ | \n$\\var{a[6]}$ | \n$\\var{a[7]}$ | \n$\\var{a[8]}$ | \n$\\var{a[9]}$ | \n
---|---|---|---|---|---|---|---|---|---|---|
Tasty Hell (g) | \n$\\var{b[0]}$ | \n$\\var{b[1]}$ | \n$\\var{b[2]}$ | \n$\\var{b[3]}$ | \n$\\var{b[4]}$ | \n$\\var{b[5]}$ | \n$\\var{b[6]}$ | \n$\\var{b[7]}$ | \n$\\var{b[8]}$ | \n$\\var{b[9]}$ | \n
Using the data above, fill in the following table.
\n\n | Sweet Heaven (g) | \nTasty Hell (g) | \n
---|---|---|
Mean weight | \n[[0]] | \n[[1]] | \n
Median weight | \n[[2]] | \n[[3]] | \n
Modal weight | \n[[4]] | \n[[5]] | \n
Range | \n[[6]] | \n[[7]] | \n
Sweet Heaven
", "Tasty Hell
"], "showFeedbackIcon": true, "prompt": "Now suppose Alice has two children. Which ice cream shop is it better for her to visit if she does not want her children to fight over who has more ice cream?
", "shuffleChoices": false, "matrix": ["2", "0"], "variableReplacements": [], "marks": 0, "scripts": {}, "showCorrectAnswer": true, "displayType": "radiogroup", "distractors": ["", ""]}], "ungrouped_variables": ["meanab", "meana", "modea", "mediana", "meanb", "modeb", "medianb", "rangea", "rangeb", "suma", "sumb"], "rulesets": {}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Given two distributions, calculate the measures of average and spread and make some decisions based on the results.
"}, "preamble": {"css": "", "js": ""}, "advice": "We denote Sweet Heaven as $s$ and Tasty Hell as $t$.
\nWe are going to start with completing the column for Sweet Heaven.
\nFirst, we need to find the sum of weights of all the scoops:
\n\\[\\begin{align} \\sum s &= \\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{suma} \\text{.}
\\end{align}\\]
The total number of measurements $n$ is $10$.
\nTherefore the mean is
\n\\[ \\begin{align} \\overline{s} &= \\frac{\\sum s}{n} \\\\[3pt]&= \\frac{\\var{suma}}{10} \\\\&= \\var{meana} \\text{.} \\end{align}\\]
\n\n
The median is the middle value. We need to sort the list in order:
\nSweet Heaven (g) | \n$\\var{asort[0]}$ | \n$\\var{asort[1]}$ | \n$\\var{asort[2]}$ | \n$\\var{asort[3]}$ | \n$\\var{asort[4]}$ | \n$\\var{asort[5]}$ | \n$\\var{asort[6]}$ | \n$\\var{asort[7]}$ | \n$\\var{asort[8]}$ | \n$\\var{asort[9]}$ | \n
---|
There is an even number of responses, so there are two numbers in the middle (5th and 6th place). To find the median, we need to find the mean of these two numbers $\\var{asort[4]}$ and $\\var{asort[5]}$:
\n\\[ \\displaystyle \\begin{align} \\frac{\\var{asort[4]} + \\var{asort[5]}}{2} &= \\frac{\\var{asort[4] + asort[5]}}{2} \\\\&= \\var{mediana} \\text{.} \\end{align}\\]
\n\n
The mode is the value that occurs the most often in the data.
\nTo find a mode, we can look at our sorted list:
\nSweet Heaven (g) | \n$\\var{asort[0]}$ | \n$\\var{asort[1]}$ | \n$\\var{asort[2]}$ | \n$\\var{asort[3]}$ | \n$\\var{asort[4]}$ | \n$\\var{asort[5]}$ | \n$\\var{asort[6]}$ | \n$\\var{asort[7]}$ | \n$\\var{asort[8]}$ | \n$\\var{asort[9]}$ | \n
---|
We notice that $\\var{modea}$ occurs the most times (3) and so $\\var{modea}$ is the mode.
\n\n
The range is the difference between the highest and the lowest value in the data.
\nTo find this, we subtract the lowest value from the highest value:
\n\\[ \\var{max(a)} - \\var{min(a)} = \\var{rangea} \\text{.}\\]
\n\n
So the first column is
\n\n | Sweet Heaven (g) | \n
---|---|
Mean weight | \n$\\var{meana}$ | \n
Median weight | \n$\\var{mediana}$ | \n
Modal weight | \n$\\var{modea}$ | \n
Range | \n$\\var{rangea}$ | \n
\n
Similarly for Tasty Hell,
\n\\[\\begin{align} \\sum t &= \\var{b[0]} + \\var{b[1]} + \\var{b[2]} + \\var{b[3]} + \\var{b[4]} + \\var{b[5]} + \\var{b[6]} + \\var{b[7]} + \\var{b[8]} + \\var{b[9]} \\\\&= \\var{sumb} \\text{.}
\\end{align}\\]
The total number of measurements $n$ is $10$ again.
\nTherefore the mean is
\n\\[ \\begin{align} \\overline{t} &= \\frac{\\sum t}{n} \\\\[3pt]&= \\frac{\\var{sumb}}{10} \\\\&= \\var{meanb} \\text{.} \\end{align}\\]
\n\n
For median, we sort the list in order:
\nTasty Hell (g) | \n$\\var{bsort[0]}$ | \n$\\var{bsort[1]}$ | \n$\\var{bsort[2]}$ | \n$\\var{bsort[3]}$ | \n$\\var{bsort[4]}$ | \n$\\var{bsort[5]}$ | \n$\\var{bsort[6]}$ | \n$\\var{bsort[7]}$ | \n$\\var{bsort[8]}$ | \n$\\var{bsort[9]}$ | \n
---|
There is an even number of responses, so there are two numbers in the middle (5th and 6th place). We find the mean of these two numbers $\\var{bsort[4]}$ and $\\var{bsort[5]}$:
\n\\[ \\displaystyle \\begin{align} \\frac{\\var{bsort[4]} + \\var{bsort[5]}}{2} &= \\frac{\\var{bsort[4] + bsort[5]}}{2} \\\\&= \\var{medianb} \\text{.} \\end{align}\\]
\n\n
For mode, we look at our sorted list:
\nTasty Hell (g) | \n$\\var{bsort[0]}$ | \n$\\var{bsort[1]}$ | \n$\\var{bsort[2]}$ | \n$\\var{bsort[3]}$ | \n$\\var{bsort[4]}$ | \n$\\var{bsort[5]}$ | \n$\\var{bsort[6]}$ | \n$\\var{bsort[7]}$ | \n$\\var{bsort[8]}$ | \n$\\var{bsort[9]}$ | \n
---|
We notice that $\\var{modeb}$ occurs the most times (2) and so $\\var{modeb}$ is the mode.
\n\n
To find the range, we subtract the lowest value from the highest value:
\n\\[ \\var{max(b)} - \\var{min(b)} = \\var{rangeb} \\text{.}\\]
\n\n
So the complete table is\u200b
\n\n | Sweet Heaven (g) | \nTasty Hell (g) | \n
---|---|---|
Mean weight | \n$\\var{meana}$ | \n$\\var{meanb}$ | \n
Median weight | \n$\\var{mediana}$ | \n$\\var{medianb}$ | \n
Modal weight | \n$\\var{modea}$ | \n$\\var{modeb}$ | \n
Range | \n$\\var{rangea}$ | \n$\\var{rangeb}$ | \n
Let's look at the differences between the two ice cream parlours:
The range of weight of Tasty Hell scoops ($\\var{rangeb}$) is far greater than that of Sweet Heaven scoops ($\\var{rangea}$).
\nThe mean weight for each shop is $\\var{meanab}$. This implies that the scoops are more-or-less the same in both shops. However, looking at the actual values as well as other measures, we can see this is not true, so the mean is not very reliable in this case.
\nWhen we compare the medians ($\\var{mediana}$ and $\\var{medianb}$), we might assume that the scoops are generally lighter in Tasty Hell. This is partly true, but there were some much heavier scoops provided by this shop as well.
\nLooking at modes ($\\var{modea}$ and $\\var{modeb}$) can be very misleading, because the modal weight for Tasty Hell is the maximum value at the same time, so it is not a reliable measure of average in this case.
\nAlice wants her children's ice creams to be very similar.
\nThis is more likely to happen in the shop with a lower range of values.
\nComparing the ranges, the range of weight of Sweet Heaven scoops ($\\var{rangea}$) is far lower than that of Tasty Hell scoops ($\\var{rangeb}$), implying Sweet Heaven is more consistent with their scoops.
"}, {"name": "Relative Frequency ", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Elliott Fletcher", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1591/"}], "advice": "The relative frequency of an outcome is the frequency of the outcome divided by the number of trials.
\nWe are told that $\\var{no_people}$ people were asked whether they preferred to buy free-range eggs or caged eggs in supermarkets and that $\\var{free_range}$ of these people said that they preferred to buy free-range eggs.
\nTo calculate the relative frequency of people who prefer buying free-range eggs we need the number of trials and the frequency of people who said that they preferred buying free-range eggs.
\nSo, the number of trials in this situation is the number of people who were asked the question, which is $\\var{no_people}$.
\nThe frequency of people who said that they preferred to buy free-range eggs is $\\var{free_range}$.
\nTherefore, the relative frequency of people who prefer buying free-range eggs is
\n\\[
\\frac{\\var{free_range}}{\\var{no_people}} = \\var{dpformat({free_range/no_people}, 2)} \\; (\\text{rounded to $2$ decimal places}).
\\]
We are told that the relative frequency of a student being taller than $150$ cm is $\\var{rel_freq}$.
\nHere, we must use the formula for relative frequency in reverse in order to estimate the number of students in the class who are taller than $150$ cm.
\nAs we are using relative frequency to calculate this number, our answer may not be completely accurate, therefore our answer will be an estimate of the actual number.
\nIf we let $n$ denote the number of students in the class who are taller than $150$ cm and if there are $\\var{no_students}$ students in the class then
\n\\[
\\begin{align}
\\frac{n}{\\var{no_students}} &= \\var{rel_freq}\\\\
n &= \\var{rel_freq} \\times \\var{no_students}\\\\
&= \\var{{rel_freq}*{no_students}}.
\\end{align}
\\]
As $n$ represents a number of people we must round our value of $n$ to the nearest integer.
\nSo, the estimated number of students in the class who are taller than $150$ cm is $\\var{dpformat({rel_freq}*{no_students},0)}$.
\n\n
i)
\nUsing the frequency table given in the question, we can calculate the sample size of the survey by adding together the frequencies of each of the different types of pets.
\nSo, the sample size of the survey is
\n\\[
\\var{dog}+\\var{cat}+\\var{hamster}+\\var{parrot} = \\var{{dog}+{cat}+{hamster}+{parrot}}.
\\]
ii)
\nTo calculate the relative frequency of a person having a dog as a pet, we divide the frequency of people in the survey who had a dog as a pet by the sample size of the survey.
\nSo, the relative frequency is
\n\\[
\\frac{\\var{dog}}{\\var{n}} = \\var{dpformat({dog/n}, 2)} \\; (\\text{rounded to $2$ decimal places}).
\\]
The relative frequency of an outcome is the frequency of the outcome divided by the number of trials.
", "variables": {"dog": {"name": "dog", "group": "Ungrouped variables", "templateType": "anything", "description": "Frequency of dog in part c
", "definition": "random(10..50)"}, "free_range": {"name": "free_range", "group": "Ungrouped variables", "templateType": "anything", "description": "Number of people who prefer free-range eggs in part a)
", "definition": "random(10..40)"}, "cat": {"name": "cat", "group": "Ungrouped variables", "templateType": "anything", "description": "Frequency of cat in part c.
", "definition": "random(10..50 except dog)"}, "parrot": {"name": "parrot", "group": "Ungrouped variables", "templateType": "anything", "description": "Frequency of guinea pig in part c.
", "definition": "random(10..50 except dog except cat except hamster)"}, "rel_freq": {"name": "rel_freq", "group": "Ungrouped variables", "templateType": "anything", "description": "Relative frequency for part b
", "definition": "random(0.1..0.9 # 0.01)"}, "n": {"name": "n", "group": "Ungrouped variables", "templateType": "anything", "description": "Sample size for part c
", "definition": "dog+cat+hamster+parrot"}, "no_students": {"name": "no_students", "group": "Ungrouped variables", "templateType": "anything", "description": "Number of students in the class for part b
", "definition": "random(20..40 #10)"}, "no_people": {"name": "no_people", "group": "Ungrouped variables", "templateType": "anything", "description": "Number of people asked in part a)
", "definition": "random(50..150 #10)"}, "hamster": {"name": "hamster", "group": "Ungrouped variables", "templateType": "anything", "description": "Frequency of hamster in part c
", "definition": "random(10..40 except dog except cat) "}}, "tags": ["Experimental Probability", "Relative Frequency", "taxonomy"], "ungrouped_variables": ["no_people", "free_range", "no_students", "rel_freq", "dog", "cat", "hamster", "parrot", "n"], "functions": {}, "preamble": {"js": "", "css": ""}, "type": "question", "variable_groups": [], "rulesets": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"description": "Calculate relative frequencies in a variety of scenarios.
", "licence": "Creative Commons Attribution 4.0 International"}, "parts": [{"notationStyles": ["plain", "en", "si-en"], "precisionPartialCredit": 0, "strictPrecision": true, "variableReplacementStrategy": "originalfirst", "allowFractions": false, "correctAnswerStyle": "plain", "precision": "2", "scripts": {}, "maxValue": "{free_range}/{no_people}", "prompt": "$\\var{no_people}$ people were asked whether they preferred to buy free-range eggs or caged eggs in supermarkets. $\\var{free_range}$ people said that they preferred to buy free-range eggs. What is the relative frequency of people who prefer buying free-range eggs? Give your answer as a decimal, to $2$ decimal places.
\n", "marks": 1, "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "correctAnswerFraction": false, "minValue": "{free_range}/{no_people}", "precisionType": "dp", "showCorrectAnswer": true, "type": "numberentry", "showPrecisionHint": true, "showFeedbackIcon": true, "precisionMessage": "You must give your answer as a decimal to 2 decimal places.
"}, {"notationStyles": ["plain", "en", "si-en"], "precisionPartialCredit": 0, "strictPrecision": false, "variableReplacementStrategy": "originalfirst", "allowFractions": false, "correctAnswerStyle": "plain", "precision": 0, "scripts": {}, "maxValue": "{no_students}*{rel_freq}", "prompt": "The heights of a class of students were measured. The relative frequency of a student being taller than $150$ cm is known to be $\\var{rel_freq}$. If there are $\\var{no_students}$ students in the class, estimate the number of students who are taller than $150$ cm.
", "marks": 1, "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "correctAnswerFraction": false, "minValue": "{no_students}*{rel_freq}", "precisionType": "dp", "showCorrectAnswer": true, "type": "numberentry", "showPrecisionHint": true, "showFeedbackIcon": true, "precisionMessage": "Round your answer to the nearest integer.
"}, {"scripts": {}, "showCorrectAnswer": true, "gaps": [{"notationStyles": ["plain", "en", "si-en"], "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "minValue": "{dog}+{cat}+{hamster}+{parrot}", "correctAnswerFraction": false, "allowFractions": false, "correctAnswerStyle": "plain", "showFeedbackIcon": true, "scripts": {}, "maxValue": "{dog}+{cat}+{hamster}+{parrot}", "showCorrectAnswer": true, "type": "numberentry", "marks": 1, "variableReplacementStrategy": "originalfirst"}, {"notationStyles": ["plain", "en", "si-en"], "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "precisionPartialCredit": 0, "strictPrecision": true, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "minValue": "{dog}/({dog}+{cat}+{hamster}+{parrot})", "allowFractions": false, "correctAnswerStyle": "plain", "precisionType": "dp", "scripts": {}, "maxValue": "{dog}/({dog}+{cat}+{hamster}+{parrot})", "showCorrectAnswer": true, "precision": "2", "type": "numberentry", "showPrecisionHint": true, "marks": 1, "showFeedbackIcon": true, "precisionMessage": "Round your answer to 2 decimal places.
"}], "type": "gapfill", "prompt": "A survey was conducted to find out what type of pet is the most common. The results are given in the table below.
\nType of Pet | \nFrequency | \n
Dog | \n$\\var{dog}$ | \n
Cat | \n$\\var{cat}$ | \n
Hamster | \n$\\var{hamster}$ | \n
Parrot | \n\n $\\var{parrot}$ \n | \n
i)
\nWhat was the sample size for the survey?
\n[[0]]
\nii)
\nWhat is the relative frequency of a person having a dog as a pet? Give your answer as a decimal, to $2$ decimal places.
\n[[1]]
\n", "variableReplacementStrategy": "originalfirst", "marks": 0, "variableReplacements": [], "showFeedbackIcon": true}]}, {"name": "Calculating Expected Values given a table of probabilities", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Elliott Fletcher", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1591/"}], "type": "question", "tags": ["Dice", "dice", "Expected values", "Expected Values", "Experimental Probability", "experimental probability", "Experimental probability", "Probability", "probability", "relative frequency", "Relative Frequency", "taxonomy", "Theoretical Probability", "theoretical probability"], "variablesTest": {"condition": "", "maxRuns": 100}, "variables": {"SW": {"templateType": "anything", "name": "SW", "description": "Probability someone goes to see Star Wars
", "definition": "random(0.4..0.51 #0.05)", "group": "Ungrouped variables"}, "Avatar": {"templateType": "anything", "name": "Avatar", "description": "Probability someone sees Avatar
", "definition": "random(0.2..0.31 #0.05)", "group": "Ungrouped variables"}, "NYSM": {"templateType": "anything", "name": "NYSM", "description": "Probability someone goes to see Now you see me
", "definition": "(1-(Avatar+SW))*3/5", "group": "Ungrouped variables"}, "TIJ": {"templateType": "anything", "name": "TIJ", "description": "Probability someone goes to see the Italian Job
", "definition": "1-(Avatar+SW+NYSM)", "group": "Ungrouped variables"}, "no_people": {"templateType": "anything", "name": "no_people", "description": "Number of people who see a movie.
", "definition": "random(100..180 #20)", "group": "Ungrouped variables"}}, "functions": {}, "statement": "There are four films being shown in a cinema on a particular day.
\nThe probability that a person buys a ticket to see each film, denoted $P(\\text{Film})$, is given in the table below.
\nFilm | \n$P(\\text{Film})$ | \nGenre | \n
Forgotten Game | \n$\\var{Avatar}$ | \nSci-Fi | \n
The Diamond Valley | \n$\\var{SW}$ | \nSci-Fi | \n
School of Return | \n$\\var{NYSM}$ | \nThriller | \n
The Silk's Nobody | \n$\\var{TIJ}$ | \nCrime | \n
$\\var{no_people}$ people each buy a ticket at the cinema to see a film of their own choosing during the day.
", "variable_groups": [], "parts": [{"correctAnswerFraction": false, "scripts": {}, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "allowFractions": false, "maxValue": "{no_people}*{Avatar}", "showFeedbackIcon": true, "prompt": "How many of these people would you expect to have bought tickets to see Forgotten Game?
", "minValue": "{no_people}*{Avatar}", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "marks": 1, "showCorrectAnswer": true}, {"correctAnswerFraction": false, "scripts": {}, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "allowFractions": false, "maxValue": "{no_people}*({Avatar}+{SW})", "showFeedbackIcon": true, "prompt": "How many of these people would you expect to have bought tickets to see a Sci-Fi film?
", "minValue": "{no_people}*({Avatar}+{SW})", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "marks": 1, "showCorrectAnswer": true}], "ungrouped_variables": ["Avatar", "SW", "NYSM", "TIJ", "no_people"], "rulesets": {}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "This question assesses the students ability to find the expected number of times an event occurs given the probability of the event occurring for a single trial and the total number of trials.
"}, "preamble": {"css": "", "js": ""}, "advice": "If we are given the probability of an event occurring in a single trial then we can calculate the expected number of times that this event would occur in a larger number of trials.
\nTo do this, we multiply the probability of the event occurring in a single trial by the total number of trials:
\n\\[\\text{Expected number of times an event occurs} = \\text{Probability of event} \\times \\text{Number of trials}.\\]
\nWe are given the probabilities that someone buys a ticket to see each film in the table below.
\nFilm | \n$P(\\text{Film})$ | \nGenre | \n
Forgotten Game | \n$\\var{Avatar}$ | \nSci-Fi | \n
The Diamond Valley | \n$\\var{SW}$ | \nSci-Fi | \n
School of Return | \n$\\var{NYSM}$ | \nThriller | \n
The Silk's Nobody | \n$\\var{TIJ}$ | \nCrime | \n
We are also told that $\\var{no_people}$ people each buy a ticket at the cinema to see a film of their own choosing during this day.
\nTo calculate the expected number of people who bought tickets to see one of these films we multiply the probability that a person buys a ticket for that film by how many people bought tickets for a film at the cinema.
\nSo the expected number of people who bought tickets to see Forgotten Game is
\n\\[
\\var{Avatar} \\times \\var{no_people} = \\var{{Avatar}*{no_people}}.
\\]
We are now asked to calculate the expected number of people who bought tickets to see a Sci-Fi film.
\nFrom the table above we can see that there are two films which belong to the Sci-Fi genre: Forgotten Game and The Diamond Valley.
\nFirstly, we need to calculate the probability that a person buys a ticket to see a Sci-Fi film, which we will denote $P(\\text{Sci-Fi})$.
\nSince the probability that a person buys a ticket to see each film is different, it would be incorrect to say that the probability that a person buys a ticket to see a Sci-Fi film is
\n\\[\\displaystyle\\frac{2}{4} = \\displaystyle\\frac{1}{2}.\\]
\nInstead we must recognise that the probability that a person buys a ticket to see a Sci-Fi film is the probability that a person buys a ticket to see either Forgotten or The Diamond Valley.
\nTherefore to calculate this probability, we add the probabilities of a person buying a ticket to see each of these films:
\n\\[
\\begin{align}
P(\\text{Sci-Fi}) &= P(\\text{Forgotten Game})+P(\\text{The Diamond Valley})\\\\
&= \\var{Avatar}+\\var{SW}\\\\
&= \\var{Avatar+SW}.
\\end{align}
\\]
Then the expected number of people who bought tickets to see a Sci-Fi film is
\n\\[
\\var{Avatar+SW} \\times \\var{no_people} = \\var{({Avatar+SW})*{no_people}}.
\\]