// Numbas version: finer_feedback_settings {"name": "Calculate probability, CDF, expected value and variance of binomial 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": {"w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..100)", "description": "", "name": "w"}, "x2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2,3,4)", "description": "", "name": "x2"}, "ans2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(tans2,3)", "description": "", "name": "ans2"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "ans1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(tans1,3)", "description": "", "name": "ans1"}, "v4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(x2>3,1,0)", "description": "", "name": "v4"}, "x1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round((w+(100-w)*(n-1))/100)", "description": "", "name": "x1"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(6..20)", "description": "", "name": "n"}, "tans1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "binomialPDF(x1,n,p)", "description": "", "name": "tans1"}, "tans2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "binomialCDF(x2,n,p)", "description": "", "name": "tans2"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.1..0.9#0.1)", "description": "", "name": "p"}, "v3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(x2>2,1,0)", "description": "", "name": "v3"}}, "ungrouped_variables": ["w", "ans1", "ans2", "n", "p", "v3", "v4", "tol", "x2", "x1", "tans1", "tans2"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Calculate probability, CDF, expected value and variance of binomial distribution, ", "functions": {}, "showQuestionGroupNames": false, "parts": [{"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}(X=\\var{x1}) = $ [[0]]

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ans2", "maxValue": "ans2", "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 $F_X(\\var{x2}) = \\operatorname{P}(X\\le\\var{x2})=$ [[0]]

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{n*p}", "minValue": "{n*p}", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{n*p*(1-p)}", "minValue": "{n*p*(1-p)}", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Find:

\n
    \n
  1. $\\operatorname{E}[X]=$ [[0]]
  2. \n
  3. $\\operatorname{Var}(X)=$ [[1]]
  4. \n
", "showCorrectAnswer": true, "marks": 0}], "statement": "

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

\n

Suppose $X \\sim \\operatorname{Binomial}(\\var{n},\\var{p})$

", "tags": ["binomial distribution", "Binomial distribution", "Binomial Distribution", "CDF", "cdf", "CDF of binomial distribution", "checked2015", "cr1", "cumulative density function", "Discrete random variables.", "distributions", "Expectation of binomial distribution", "MAS1604", "MAS2304", "probability", "Probability", "random variables", "statistics", "tested1", "variance of binomial distribution"], "rulesets": {"std": ["all", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": "Numbas.jme.display.texOps['prob'] = function(thing,texArgs) {\n return '\\\\operatorname{P}\\\\left( '+texArgs.join(', ')+' \\\\right)';\n}"}, "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

Now runs after stats extension box ticked.

\n

Added description.

\n

Checked calculation.

\n

31/07/2012:

\n

Added tags.

\n

Question appears to be working correctly.

\n

 20/12/2012:

\n

Rounding seems to be OK. Added cr1 tag.  Replaced sum of pdf values by built in binomialcdf function from jstats.

\n

Checked calculation, OK. Added tested1 tag.

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

$X \\sim \\operatorname{Binomial}(n,p)$. Find $P(X=a)$, $P(X \\leq b)$, $E[X],\\;\\operatorname{Var}(X)$.

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

a)

\n

\\[ \\simplify[std,!otherNumbers]{prob(X = {x1}) = {n}! / ({n -x1}! * {x1}!) * {p} ^ {x1} * (1 -{p}) ^ {n -x1}} = \\var{ans1}\\]

\n

to 3 decimal places.

\n

b)

\n

We have:

\n

\\begin{align}
F_X (\\var{x2}) &= \\operatorname{P}(X \\le \\var{x2}) = \\simplify[std]{ prob(X = 0) + prob(X = 1) + prob(X = 2) + {v3} * prob(X = 3) + {v4} * prob(X = 4)} \\\\
&= \\simplify[unitFactor,zeroTerm,zeroFactor]{(1 -{p}) ^ {n} + {n} * (1 -{p}) ^ {n -1} * {p} + {(n * (n -1)) / 2} * (1 -{p}) ^ {n -2} * {p} ^ 2 + {v3} * {comb(n , 3)} * (1 -{p}) ^ {n -3} * {p} ^ 3 + {v4} * {comb(n , 4)} * (1 -{p}) ^ {n -4} * {p} ^ 4} \\\\
&= \\var{ans2} 
\\end{align}

\n

to 3 decimal places.

\n

c)

\n

For the binomial distribution $\\operatorname{Binomial}(n,p)$ we have:

\n

\\begin{align}
\\operatorname{E}[X] &= np \\\\
\\operatorname{Var}(X) &= np(1-p)
\\end{align}

\n

Hence in this case:

\n

\\begin{align}
\\operatorname{E}[X] &= \\var{n} \\times \\var{p} = \\var{n*p} \\\\
\\operatorname{Var}(X) &= \\var{n} \\times \\var{p} \\times \\var{(1-p)} = \\var{n*p*(1-p)}
\\end{align}

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