// Numbas version: finer_feedback_settings {"name": "Calculate probability, expected value and variance of a geometric distribution, ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "ans": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(tans,3)", "description": "", "name": "ans"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "arz(y2,y3,[1,2,3,4,5,6,7])", "description": "", "name": "v"}, "y3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "y2+u", "description": "", "name": "y3"}, "y2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..3)", "description": "", "name": "y2"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.3..0.7#0.05)", "description": "", "name": "p"}, "tans": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(geometricPDF(y1,p),4)", "description": "", "name": "tans"}, "y1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..7)", "description": "", "name": "y1"}, "u": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..4)", "description": "", "name": "u"}, "ans1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(tans1,3)", "description": "", "name": "ans1"}, "tans1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(geometricCDF(y3,p)-geometricCDF(y2-1,p),4)", "description": "", "name": "tans1"}}, "ungrouped_variables": ["ans1", "ans", "p", "u", "tol", "v", "y1", "tans", "y3", "y2", "tans1"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Calculate probability, expected value and variance of a geometric distribution, ", "functions": {"arz": {"type": "list", "language": "jme", "definition": "map(if(xn,0,1),x,a)", "parameters": [["m", "number"], ["n", "number"], ["a", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ans", "maxValue": "ans", "precision": "3", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 1}], "type": "gapfill", "prompt": "

Compute $\\operatorname{P}(W=\\var{y1}) = $ [[0]]

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

Compute $\\operatorname{P}(\\var{y2} \\le W \\le \\var{y3}) =$ [[0]] (enter your answer to 3 decimal places)

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

Find:

\n

1. $\\operatorname{E}[W] = $ [[0]]

\n

2. $\\operatorname{Var}(W)=$ [[1]]

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

Enter your answers to the following questions to 3 decimal places.

\n

Suppose $W\\sim \\operatorname{Geometric}(\\var{p})$

", "tags": ["checked2015", "discrete random variables", "distributions", "expectation of geometric distribution", "geometric distribution", "Geometric Distribution", "MAS1604", "MAS2304", "probability", "Probability", "random variables", "sr", "statistics", "tested1", "udf", "variance of geometric distribution"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

7/07/2012:

\n

Added tags.

\n

Cannot access stats extension at present, so question does not run. Issue posted.

\n

Set new tolerance variable tol=0.001 for first two answers.

\n

Calculation to be tested under Test Run.

\n

22/07/2012:

\n

Added description.

\n

Can check calculation now stats extension box ticked.

\n

Calculations checked.

\n

31/07/2012:

\n

 Added tags.

\n

Question appears to be working correctly.

\n

20/12/2012:

\n

Checked calculations against standard tables, OK.

\n

Added tested1 tag.

\n

User defined function arz picks out values in an array a lying between given values m and n.

\n

arz(m,n,a)=map(if(x<m or x >n,0,1),x,a). Added udf tag.

\n

Extra rounding introduced for variables tans1, tans. Added tag sr.

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

$W \\sim \\operatorname{Geometric}(p)$. Find $P(W=a)$, $P(b \\le W \\le c)$, $E[W]$, $\\operatorname{Var}(W)$.

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

a)

\n

If $W \\sim \\operatorname{Geometric}(p)$ then

\n

\\[\\operatorname{P}(W=w)=p \\times (1-p)^{w-1}\\]

\n

Hence:

\n

\\[ \\operatorname{P}(W= \\var{y1}) = \\simplify[!otherNumbers,zeroPower,unitFactor]{{p}*(1-{p})^{y1-1}} = \\var{tans} \\approx \\var{ans}\\]

\n

to 3 decimal places.

\n

b)

\n

We have:

\n

\\begin{align}
\\operatorname{P}(\\var{y2} \\le W \\le \\var{y3}) &= \\sum_{w=\\var{y2}}^{w=\\var{y3}}\\var{p}\\times(1-\\var{p})^{w-1} \\\\
&= \\simplify[unitFactor,zeroTerm,zeroFactor]{{v[0]}*{p}+{v[1]}*{p}*{1-p} +{v[2]}*{p}*{1-p}^2 +{v[3]}*{p}*{1-p}^3 +{v[4]}*{p}*{1-p}^4 +{v[5]}*{p}*{1-p}^5+{v[6]}*{p}*{1-p}^6} \\\\
&= \\var{tans1} \\\\
&\\approx \\var{ans1}
\\end{align}

\n

to 3 decimal places.

\n

c)

\n

For the Geometric distribution $\\operatorname{Geometric}(p)$ we have:

\n

\\begin{align}
\\operatorname{E}[W] &= \\frac{1}{p} \\\\ \\\\
\\operatorname{Var}(W) &= \\frac{1-p}{p^2}
\\end{align}

\n

Hence in this case:

\n

\\begin{align}
\\operatorname{E}[W] &= \\simplify{1/{p}} = \\var{precround(1/p,3)} \\\\[0.5em]
\\operatorname{Var}(W) &= \\simplify[all,!collectNumbers,!otherNumbers]{(1-{p})/({p}^2)} = \\var{precround((1-p)/p^2,3)}
\\end{align}

\n

to 3 decimal places.

", "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/"}]}