// Numbas version: exam_results_page_options {"name": "Binomial Distribution", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"licence": "None specified", "description": ""}, "variables": {"nballs": {"templateType": "randrange", "group": "Ungrouped variables", "name": "nballs", "definition": "random(1..20#1)", "description": "

Number of selections

"}, "x": {"templateType": "randrange", "group": "Ungrouped variables", "name": "x", "definition": "random(10..100#1)", "description": "

Number of white balls

"}, "y": {"templateType": "randrange", "group": "Ungrouped variables", "name": "y", "definition": "random(10..100#1)", "description": "

Number of red balls

"}, "total_balls": {"templateType": "anything", "group": "Ungrouped variables", "name": "total_balls", "definition": "x+y", "description": ""}, "rballs": {"templateType": "anything", "group": "Ungrouped variables", "name": "rballs", "definition": "random(0..nballs)", "description": "

Number of red balls selected

"}, "wballs": {"templateType": "anything", "group": "Ungrouped variables", "name": "wballs", "definition": "random(1..min(nballs,5))", "description": "

Number of white balls selected

"}, "prob_n_red": {"templateType": "anything", "group": "Ungrouped variables", "name": "prob_n_red", "definition": "binomialpdf(rballs,nballs,1-p)", "description": "

Probability of a certain number of balls being red

"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "name": "p", "definition": "x/(x+y)", "description": "

Probability that a white ball is drawn

"}, "prob_zero_white": {"templateType": "anything", "group": "Ungrouped variables", "name": "prob_zero_white", "definition": "binomialpdf(0,nballs,p)", "description": ""}, "oneminusp": {"templateType": "anything", "group": "Ungrouped variables", "name": "oneminusp", "definition": "1-p", "description": "

Probability of picking a red ball

"}, "prob_white_less_than": {"templateType": "anything", "group": "Ungrouped variables", "name": "prob_white_less_than", "definition": "binomialcdf(wballs-1,nballs,p)", "description": "

probability less than so many balls are white

"}}, "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "information", "variableReplacements": [], "steps": [{"minValue": "p", "scripts": {}, "correctAnswerFraction": false, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "allowFractions": false, "marks": 1, "prompt": "

What is the probability that the ball is white?

", "precisionPartialCredit": 0, "strictPrecision": true, "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "correctAnswerStyle": "plain", "precision": "5", "maxValue": "p", "showPrecisionHint": true, "precisionMessage": "You have not given your answer to the correct precision.", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "showCorrectAnswer": true, "precisionType": "dp"}, {"minValue": "1-p", "scripts": {}, "correctAnswerFraction": false, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "allowFractions": false, "marks": 1, "prompt": "

What is the probability that the ball is red? Please enter you answer as a fraction or as a decimal with 5 significant figures.

", "precisionPartialCredit": 0, "strictPrecision": false, "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "correctAnswerStyle": "plain", "precision": "5", "maxValue": "1-p", "showPrecisionHint": true, "precisionMessage": "You have not given your answer to the correct precision.", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "showCorrectAnswer": true, "precisionType": "dp"}], "scripts": {}, "marks": 0, "prompt": "

A ball is chosen at random from the bag.

", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "showCorrectAnswer": true, "stepsPenalty": 0}, {"type": "information", "variableReplacements": [], "steps": [{"minValue": "prob_n_red", "scripts": {}, "correctAnswerFraction": false, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "allowFractions": false, "marks": 1, "prompt": "

Find the probability that $\\var{rballs}$ of the selected balls are red.

", "precisionPartialCredit": 0, "strictPrecision": false, "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "correctAnswerStyle": "plain", "precision": "3", "maxValue": "prob_n_red", "showPrecisionHint": true, "precisionMessage": "You have not given your answer to the correct precision.", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "showCorrectAnswer": true, "precisionType": "dp"}, {"minValue": "prob_zero_white", "scripts": {}, "correctAnswerFraction": false, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "allowFractions": false, "marks": 1, "prompt": "

Find the probability that $0$ balls are white.

", "precisionPartialCredit": 0, "strictPrecision": false, "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "correctAnswerStyle": "plain", "precision": "3", "maxValue": "prob_zero_white", "showPrecisionHint": true, "precisionMessage": "You have not given your answer to the correct precision.", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "showCorrectAnswer": true, "precisionType": "dp"}, {"minValue": "prob_white_less_than", "scripts": {}, "correctAnswerFraction": false, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "allowFractions": false, "marks": 1, "prompt": "

Find the probability that fewer than $\\var{wballs}$ of the selected balls are white.

", "precisionPartialCredit": 0, "strictPrecision": false, "mustBeReduced": false, "variableReplacements": [], "mustBeReducedPC": 0, "correctAnswerStyle": "plain", "precision": "3", "maxValue": "prob_white_less_than", "showPrecisionHint": true, "precisionMessage": "You have not given your answer to the correct precision.", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "showCorrectAnswer": true, "precisionType": "dp"}], "scripts": {}, "marks": 0, "prompt": "

A ball is chosen at random from the bag, its colour noted, then returned to the bag. This is repeated $\\var{nballs}$ times.

", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "showCorrectAnswer": true, "stepsPenalty": 0}], "name": "Binomial Distribution", "advice": "

Part (a)

\n

There are $\\var{x}$ white balls and $\\var{y}$ red balls. Thus, there are a total of $\\var{x}+\\var{y}=\\var{total_balls}$ balls.

\n

i) The probability of picking a white ball is $\\frac{Number White Balls}{TotalNumberBalls} = \\frac{\\var{x}}{\\var{total_balls}} = \\var{p}$.

\n

ii) The probability of picking a red ball is $\\frac{Number Red Balls}{TotalNumberBalls} = \\frac{\\var{y}}{\\var{total_balls}} = \\var{1-p}$

\n

\n

Part (b)

\n

As $\\var{nballs}$ balls are selected with replacement and there are only two colours of ball, we have a binomial distibution. Let $X$ be the number of white balls selected, then $X\\sim B(\\var{nballs},p)$, where $p=\\var{p}$. Similarly, let $Y$ be the number of red balls selected, then  $Y\\sim B(\\var{nballs},q)$, where $q=\\var{oneminusp}$.

\n

i) The probability that exactly $\\var{rballs}$ of the selected balls are red is thus given by:

\n

${\\var{nballs} \\choose \\var{rballs}} q^\\var{rballs}(1-q)^{\\var{nballs}-\\var{rballs}} = \\var{prob_n_red}$.

\n

ii) The probability that none of the selected balls are white is given by:

\n

${\\var{nballs} \\choose \\var{0}} p^\\var{0}(1-p)^{\\var{nballs}} = (1-p)^{\\var{nballs}} = \\var{prob_zero_white}$.

\n

iii) For this part we need to find the cumulative binomial probability, the probability that less than $\\var{wballs}$ ball are white is given by.

\n

$\\sum_{i=0}^{\\var{wballs}-1}{\\var{nballs} \\choose \\var{i}} p^\\var{i}(1-p)^{\\var{nballs}-i} = \\var{prob_white_less_than}$.

\n

\n

\n

", "variablesTest": {"maxRuns": 100, "condition": ""}, "extensions": ["stats"], "tags": [], "statement": "

A bag contains $\\var{x}$ white balls and $\\var{y}$ red balls. 

", "rulesets": {}, "ungrouped_variables": ["x", "y", "p", "wballs", "rballs", "prob_zero_white", "nballs", "prob_n_red", "prob_white_less_than", "total_balls", "oneminusp"], "type": "question", "contributors": [{"name": "Edward Hall", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1824/"}]}]}], "contributors": [{"name": "Edward Hall", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1824/"}]}