// Numbas version: finer_feedback_settings {"name": "Calculate expectation and a probability from a frequency table, , , ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [{"variables": ["idef", "thing", "episodes", "period", "activity"], "name": "Strings"}, {"variables": ["p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8", "probabilities", "values"], "name": "Probabilities"}, {"variables": ["r", "s", "t", "t1", "t2", "u1", "u2", "u3", "d"], "name": "Stuff to generate probabilities"}], "variables": {"p4": {"templateType": "anything", "group": "Probabilities", "definition": "t-p8-p7-p6-p5", "description": "", "name": "p4"}, "expected_number": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x*y,[x,y],zip(probabilities,values)))", "description": "", "name": "expected_number"}, "u2": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "u1", "description": "", "name": "u2"}, "p1": {"templateType": "anything", "group": "Probabilities", "definition": "p0+t1", "description": "", "name": "p1"}, "p3": {"templateType": "anything", "group": "Probabilities", "definition": "r-p0-p1-p2", "description": "", "name": "p3"}, "t": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "100-r", "description": "", "name": "t"}, "probexceed": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(if(j>expected_number,probabilities[j],0),j,0..8))", "description": "", "name": "probexceed"}, "values": {"templateType": "anything", "group": "Probabilities", "definition": "list(0..8)", "description": "", "name": "values"}, "thing": {"templateType": "string", "group": "Strings", "definition": "\"airline\"", "description": "", "name": "thing"}, "u3": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "u1", "description": "", "name": "u3"}, "u1": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "round(d*random(70..100)/100)", "description": "", "name": "u1"}, "expect_int": {"templateType": "anything", "group": "Ungrouped variables", "definition": "floor(expected_number)", "description": "", "name": "expect_int"}, "activity": {"templateType": "string", "group": "Strings", "definition": "\"luggage handling\"", "description": "", "name": "activity"}, "probabilities": {"templateType": "anything", "group": "Probabilities", "definition": "map(x/100,x,[p0,p1,p2,p3,p4,p5,p6,p7,p8])", "description": "

Probability of there being $i$ episodes

", "name": "probabilities"}, "d": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "round(t/15)", "description": "", "name": "d"}, "episodes": {"templateType": "string", "group": "Strings", "definition": "\"complaints\"", "description": "", "name": "episodes"}, "t2": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "t1", "description": "", "name": "t2"}, "p8": {"templateType": "anything", "group": "Probabilities", "definition": "d", "description": "", "name": "p8"}, "p7": {"templateType": "anything", "group": "Probabilities", "definition": "p8+u1", "description": "", "name": "p7"}, "p5": {"templateType": "anything", "group": "Probabilities", "definition": "p6+u3", "description": "", "name": "p5"}, "idef": {"templateType": "string", "group": "Strings", "definition": "\"an\"", "description": "", "name": "idef"}, "p2": {"templateType": "anything", "group": "Probabilities", "definition": "p1+t2", "description": "", "name": "p2"}, "t1": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "round(s*random(70..100)/100)", "description": "", "name": "t1"}, "r": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "random(45..65)", "description": "", "name": "r"}, "s": {"templateType": "anything", "group": "Stuff to generate probabilities", "definition": "round(r/10)", "description": "", "name": "s"}, "p0": {"templateType": "anything", "group": "Probabilities", "definition": "s", "description": "", "name": "p0"}, "p6": {"templateType": "anything", "group": "Probabilities", "definition": "p7+u2", "description": "", "name": "p6"}, "period": {"templateType": "string", "group": "Strings", "definition": "\"day\"", "description": "", "name": "period"}}, "ungrouped_variables": ["expected_number", "expect_int", "probexceed"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Calculate expectation and a probability from a frequency table, , , ", "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "expected_number", "maxValue": "expected_number", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 2}], "type": "gapfill", "prompt": "

Find the expected number of {episodes} per {period}.

\n

Expected number = [[0]]

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "probexceed", "maxValue": "probexceed", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 2}], "type": "gapfill", "prompt": "

What is the probability that the number of {episodes} will exceed the expected number?

\n

Probability = [[0]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

The probabilities that {idef} {thing} will receive {episodes} per {period} about its {activity} are given by the following table:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Complaints{values[0]}{values[1]}{values[2]}{values[3]}{values[4]}{values[5]}{values[6]}{values[7]}{values[8]}
Probability{probabilities[0]}{probabilities[1]}{probabilities[2]}{probabilities[3]}{probabilities[4]}{probabilities[5]}{probabilities[6]}{probabilities[7]}{probabilities[8]}
\n

Answer the following two parts, giving your answers to $2$ decimal places.

", "tags": ["checked2015", "discrete distribution", "expectation", "expected value", "MAS1604", "MAS2304", "MAS8380", "MAS8401", "mass function", "pmf", "PMF", "Probability", "probability", "probability mass function", "query", "sc", "statistics", "tested1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

7/07/2012:

\n

Added tags.

\n

Checked calculation.

\n

22/07/2012:

\n

Added description.

\n

Ticked stats extension box.

\n

31/07/2012:

\n

Added tags.

\n

Question appears to be working correctly.

\n

20/12/2012:

\n

Could increase the number of scenarios by using random string variables. Query tag added for that.

\n

Also very cumbersome use of variables. But no change proposed for now.

\n

Checked calculation, OK. Added tested1 tag.

\n

21/12/2012:

\n

Although asks for solution to 2 dps, there is no rounding as the raw values are to 2 dps. Added sc tag for possible scenarios.

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

Given a probability mass function $P(X=i)$ with outcomes $i \\in \\{0,1,2,\\ldots 8\\}$, find the expectation $E$ and $P(X \\gt E)$.

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

a)

\n

The expected number of {episodes} is given by:

\n

\\[ \\simplify[]{{probabilities[0]}*{values[0]} + {probabilities[1]}*{values[1]} + {probabilities[2]}*{values[2]} + {probabilities[3]}*{values[3]} + {probabilities[4]}*{values[4]} + {probabilities[5]}*{values[5]} + {probabilities[6]}*{values[6]} + {probabilities[7]}*{values[7]} + {probabilities[8]}*{values[8]}} = \\var{expected_number} \\]

\n

b)

\n

We want the probability that the number of {episodes} exceeds $\\var{expected_number}$.

\n

Since the number of {episodes} is a whole number, this is the same as the probability that the number is $\\var{expect_int+1}$ or more and is

\n

\\[\\sum_{i=\\var{expect_int+1}}^{i=8} \\left( \\text{Probability}(\\var{episodes} = i ) \\right)= \\simplify[zeroTerm]{ {if(expect_int<1,probabilities[1],0)} + {if(expect_int<2,probabilities[2],0)} + {if(expect_int<3,probabilities[3],0)} + {if(expect_int<4,probabilities[4],0)} + {if(expect_int<5,probabilities[5],0)} + {if(expect_int<6,probabilities[6],0)} + {if(expect_int<7,probabilities[7],0)} + {if(expect_int<8,probabilities[8],0)}} = \\var{probexceed}\\]

", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}