// Numbas version: finer_feedback_settings {"name": "Hugh's copy of Relative Frequency ", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"extensions": [], "statement": "

The relative frequency of an outcome is the frequency of the outcome divided by the number of trials.

", "rulesets": {}, "variables": {"no_people": {"group": "Ungrouped variables", "name": "no_people", "templateType": "anything", "definition": "random(50..150 #10)", "description": "

Number of people asked in part a)

"}, "dog": {"group": "Ungrouped variables", "name": "dog", "templateType": "anything", "definition": "random(10..50)", "description": "

Frequency of dog in part c

"}, "parrot": {"group": "Ungrouped variables", "name": "parrot", "templateType": "anything", "definition": "random(10..50 except dog except cat except hamster)", "description": "

Frequency of guinea pig in part c.

"}, "free_range": {"group": "Ungrouped variables", "name": "free_range", "templateType": "anything", "definition": "random(10..40)", "description": "

Number of people who prefer free-range eggs in part a)

"}, "cat": {"group": "Ungrouped variables", "name": "cat", "templateType": "anything", "definition": "random(10..50 except dog)", "description": "

Frequency of cat in part c.

"}, "no_students": {"group": "Ungrouped variables", "name": "no_students", "templateType": "anything", "definition": "random(20..40 #10)", "description": "

Number of students in the class for part b

"}, "hamster": {"group": "Ungrouped variables", "name": "hamster", "templateType": "anything", "definition": "random(10..40 except dog except cat) ", "description": "

Frequency of hamster in part c

"}, "rel_freq": {"group": "Ungrouped variables", "name": "rel_freq", "templateType": "anything", "definition": "random(0.1..0.9 # 0.01)", "description": "

Relative frequency for part b

"}, "n": {"group": "Ungrouped variables", "name": "n", "templateType": "anything", "definition": "dog+cat+hamster+parrot", "description": "

Sample size for part c

"}}, "functions": {}, "name": "Hugh's copy of Relative Frequency ", "variablesTest": {"condition": "", "maxRuns": 100}, "tags": ["Experimental Probability", "Relative Frequency", "taxonomy"], "preamble": {"css": "", "js": ""}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Calculate relative frequencies in a variety of scenarios.

"}, "ungrouped_variables": ["no_people", "free_range", "no_students", "rel_freq", "dog", "cat", "hamster", "parrot", "n"], "variable_groups": [], "parts": [{"mustBeReduced": false, "strictPrecision": true, "correctAnswerStyle": "plain", "marks": 1, "precision": "2", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "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

", "maxValue": "{free_range}/{no_people}", "minValue": "{free_range}/{no_people}", "precisionMessage": "

You must give your answer as a decimal to 2 decimal places.

", "precisionPartialCredit": 0, "correctAnswerFraction": false, "precisionType": "dp", "showFeedbackIcon": true, "allowFractions": false, "scripts": {}, "mustBeReducedPC": 0, "showCorrectAnswer": true, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "showPrecisionHint": true}, {"mustBeReduced": false, "strictPrecision": false, "correctAnswerStyle": "plain", "marks": 1, "precision": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "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.

", "maxValue": "{no_students}*{rel_freq}", "minValue": "{no_students}*{rel_freq}", "precisionMessage": "

Round your answer to the nearest integer.

", "precisionPartialCredit": 0, "correctAnswerFraction": false, "precisionType": "dp", "showFeedbackIcon": true, "allowFractions": false, "scripts": {}, "mustBeReducedPC": 0, "showCorrectAnswer": true, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "showPrecisionHint": true}, {"showFeedbackIcon": true, "marks": 0, "scripts": {}, "showCorrectAnswer": true, "gaps": [{"maxValue": "{dog}+{cat}+{hamster}+{parrot}", "correctAnswerStyle": "plain", "minValue": "{dog}+{cat}+{hamster}+{parrot}", "mustBeReduced": false, "correctAnswerFraction": false, "allowFractions": false, "showFeedbackIcon": true, "marks": 1, "scripts": {}, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true}, {"maxValue": "{dog}/({dog}+{cat}+{hamster}+{parrot})", "correctAnswerStyle": "plain", "minValue": "{dog}/({dog}+{cat}+{hamster}+{parrot})", "showCorrectAnswer": true, "strictPrecision": true, "mustBeReduced": false, "precisionPartialCredit": 0, "precisionMessage": "

Round your answer to 2 decimal places.

", "correctAnswerFraction": false, "marks": 1, "showFeedbackIcon": true, "precisionType": "dp", "scripts": {}, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "allowFractions": false, "variableReplacements": [], "precision": "2", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": true}], "variableReplacements": [], "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.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Type of PetFrequency
Dog$\\var{dog}$
Cat$\\var{cat}$
Hamster$\\var{hamster}$
Parrot\n

$\\var{parrot}$

\n
\n

\n

i) 

\n

What was the sample size for the survey?

\n

[[0]]

\n

ii)

\n

What 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"}], "advice": "

The relative frequency of an outcome is the frequency of the outcome divided by the number of trials.

\n

a)

\n

We 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. 

\n

To 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.

\n

So, the number of trials in this situation is the number of people who were asked the question, which is $\\var{no_people}$.

\n

The frequency of people who said that they preferred to buy free-range eggs is $\\var{free_range}$.

\n

Therefore, 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}).
\\] 

\n

b)

\n

We are told that the relative frequency of a student being taller than $150$ cm is $\\var{rel_freq}$.

\n

Here, 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.

\n

As 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.

\n

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

\n

As $n$ represents a number of people we must round our value of $n$ to the nearest integer.

\n

So, the estimated number of students in the class who are taller than $150$ cm is $\\var{dpformat({rel_freq}*{no_students},0)}$.

\n

c)

\n

\n

i) 

\n

Using 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.

\n

So, the sample size of the survey is 

\n

\\[
\\var{dog}+\\var{cat}+\\var{hamster}+\\var{parrot} = \\var{{dog}+{cat}+{hamster}+{parrot}}.
\\]

\n

ii) 

\n

To 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.

\n

So, the relative frequency is 

\n

\\[
\\frac{\\var{dog}}{\\var{n}} = \\var{dpformat({dog/n}, 2)} \\; (\\text{rounded to $2$ decimal places}).
\\]

\n

", "type": "question", "contributors": [{"name": "Hugh O'Donnell", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2158/"}]}]}], "contributors": [{"name": "Hugh O'Donnell", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2158/"}]}