// Numbas version: exam_results_page_options {"name": "Sampling with and without replaement - binomial, hypergeometric, and Poisson approximation, ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"batch": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'batch'", "description": "", "name": "batch"}, "howmany": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "howmany"}, "thismany": {"templateType": "anything", "group": "Ungrouped variables", "definition": "t*random(100..160#20)+(1-t)*random(100..170#10)", "description": "", "name": "thismany"}, "tpapprox": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-e^(-m)*(1+m+m^2/2)", "description": "", "name": "tpapprox"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.0001", "description": "", "name": "tol"}, "tbin": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-binomialcdf(2,s,1-p)", "description": "", "name": "tbin"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0,1)", "description": "", "name": "t"}, "items": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'items'", "description": "", "name": "items"}, "bin": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(tbin,4)", "description": "", "name": "bin"}, "percent": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(t=0,10,random(5,10))", "description": "", "name": "percent"}, "thyp": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-hypgeomcdf(howmany-1,thismany,round(thismany*percent/100),s)", "description": "", "name": "thyp"}, "something": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'defectives'", "description": "", "name": "something"}, "s": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(15..35#5)", "description": "", "name": "s"}, "hyp": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-hypgeomcdf(howmany-1,thismany,round(thismany*percent/100),s),4)", "description": "", "name": "hyp"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-percent/100", "description": "", "name": "p"}, "papprox": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(tpapprox,4)", "description": "", "name": "papprox"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "s*percent/100", "description": "", "name": "m"}}, "ungrouped_variables": ["bin", "tpapprox", "howmany", "thismany", "items", "percent", "batch", "hyp", "p", "m", "papprox", "t", "tol", "s", "thyp", "tbin", "something"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Sampling with and without replaement - binomial, hypergeometric, and Poisson approximation, ", "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "bin+tol", "minValue": "bin-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Compute $P(X \\ge \\var{howmany})$ when sampling is with replacement.

\n

$P(X \\ge \\var{howmany})=\\;$[[0]] (to 4 decimal places). 

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "hyp+tol", "minValue": "hyp-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Compute $P(X \\ge \\var{howmany})$ when sampling is without replacement.

\n

$P(X \\ge \\var{howmany})=\\;$[[0]] (to 4 decimal places). 

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "papprox+tol", "minValue": "papprox-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Repeat Part a) using a suitable approximation:

\n

$P(X \\ge \\var{howmany})=\\;$[[0]] (to 4 decimal places). 

\n

 

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

A {batch} of $\\var{thismany}$ {items} has $\\var{percent}$% {something}.

\n

A sample of size $\\var{s}$ is taken.

\n

$X$ is the number of {something} in the sample.

\n

Note that for the second part of this example we expect you to use R to calculate the probability.

", "tags": ["approximating binomial distribution", "binomial", "Binomial distribution", "binomial distribution", "Binomial Distribution", "checked2015", "discrete distribution", "distribution", "hypergeometric distribution", "MAS1604", "MAS2304", "Poisson distribution", "poisson distribution", "Probability", "R", "replacement", "sample", "sampling", "sc", "statistical distribution", "statistics", "without replacement"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

5/02/2013:

\n

First draft finished.

\n

Uses the jstats hypergeometric function hypgeomcdf(m-1,N,k,n)

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

Three parts. A sample of size $n$ is taken from $N$ where $k$ of the items are known to be defective and the task is to find the probability that more than $m$ defectives are in the sample. First part is sampling with replacement (binomial), second is sampling without replacement, (hypergeometric) and the last part uses the Poisson approximation to the first part.

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

a)

\n

For sampling with replacement we have $X \\sim \\operatorname{Bin}\\left(\\var{s},\\var{percent/100}\\right)$.

\n

Hence:

\n

$P(X \\ge \\var{howmany}) = 1-P(X \\le \\var{howmany-1})=1-\\var{1-tbin}=\\var{bin}$ to 4 decimal places.

\n

b)

\n

For sampling without replacement we have $X \\sim \\operatorname{Hypergeometric}(N=\\var{thismany},\\;n=\\var{s}, p=\\var{percent/100})$.

\n

Since $P(X \\ge \\var{howmany})=1-P(X \\le \\var{howmany-1})$ we calculate $P(X \\le \\var{howmany-1})$ using the hypergeometric probability distribution as calculated in R as we are counting the number of ways of selecting $\\var{howmany-1}$ from $\\var{round(thismany*percent/100)}$ defectives and the other $\\var{s+1-howmany}$ in the sample from the $\\var{round(thismany*(1-percent/100))}$ non-defectives.

\n

The R expression we use for the probability is:

\n

$\\operatorname{phyper}(\\var{howmany-1},\\var{round(thismany*percent/100)},\\var{round(thismany*(1-percent/100))},\\var{s})=\\var{1-thyp}$

\n

Hence the answer for sampling without replacement is $1-\\var{1-thyp}=\\var{hyp}$ t0 4 decimal places.

\n

c)

\n

We can approximate the random variable $X$ from part a) which follows a binomial distribution by the Poisson distribution $\\operatorname{Poisson}\\left(\\mu=\\var{s}\\times \\var{percent/100}\\right)=\\operatorname{Poisson}(\\var{m})$.

\n

We have $P(X \\ge \\var{howmany}) = 1-P(X \\le \\var{howmany-1})=1-\\var{1-tpapprox}=\\var{papprox}$ to 4 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/"}]}