// Numbas version: finer_feedback_settings {"name": "Assessment: calculate confidence interval for the proportion", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"preamble": {"js": "", "css": ""}, "name": "Assessment: calculate confidence interval for the proportion", "tags": [], "metadata": {"description": "
\nCalculate confidence interval for the mean, sample variance n>30
", "licence": "Creative Commons Attribution 4.0 International"}, "advice": "\nThe estimate for the population proportion is $\\hat{p} =\\frac{{\\var{prop1[Index]}}}{\\var{n1[Index]}}=\\var{precround(p_hat,3)}$
\n\nThe estimate for the standard error associated with $\\hat{p}$ is $=\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n}}=\\sqrt{\\frac{\\var{precround(p_hat,3)}\\times (1-\\var{precround(p_hat,3)})}{\\var{n1[Index]}}}=\\var{se}$
\n\n
To construct a $\\var{percentage}$% confidence interval, $Z_\\frac{\\alpha}{2}=Z_\\frac{\\var{alpha2}}{2} = \\var{Z}$
\n\nPutting this information together, the lower bound of the $\\var{percentage}$% confidence interval is:
\n$\\hat{p} -Z_\\frac{\\alpha}{2}\\times\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{\\var{n1[Index]}}}=\\var{precround(p_hat,3)} -\\var{Z}\\times \\var{se}=\\var{precround(lower,2)}$
\nThe upper bound of the $\\var{percentage}$% confidence interval is:
\n$\\hat{p} +Z_\\frac{\\alpha}{2}\\times\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{\\var{n1[Index]}}}=\\var{precround(p_hat,3)} +\\var{Z}\\times \\var{se}=\\var{precround(upper,2)}$
\n\n\n\n", "variablesTest": {"condition": "", "maxRuns": 100}, "functions": {}, "ungrouped_variables": ["upper", "Index", "percentage", "Z", "alpha", "lower", "se"], "variables": {"p_hat": {"description": "", "name": "p_hat", "group": "Unnamed group", "templateType": "anything", "definition": "prop1[Index]/n1[Index]"}, "scenario2": {"description": "", "name": "scenario2", "group": "Unnamed group", "templateType": "anything", "definition": "[\"randomly chosen registered voters. It is found that\", \"businesses in Cork city found that\"]\n"}, "n1": {"description": "", "name": "n1", "group": "Unnamed group", "templateType": "anything", "definition": "[random(500..700#20),random(100..250#10)]"}, "upper": {"description": "", "name": "upper", "group": "Ungrouped variables", "templateType": "anything", "definition": "p_hat+Z*sqrt((p_hat*(1-p_hat))/n1[Index])"}, "alpha2": {"description": "", "name": "alpha2", "group": "Unnamed group", "templateType": "anything", "definition": "alpha*2"}, "percentage": {"description": "", "name": "percentage", "group": "Ungrouped variables", "templateType": "anything", "definition": "random([95,99])"}, "lower": {"description": "", "name": "lower", "group": "Ungrouped variables", "templateType": "anything", "definition": "p_hat-Z*sqrt((p_hat*(1-p_hat))/n1[Index])"}, "Z": {"description": "", "name": "Z", "group": "Ungrouped variables", "templateType": "anything", "definition": "precround(normalinv(1-alpha,0,1),2)"}, "prop1": {"description": "", "name": "prop1", "group": "Unnamed group", "templateType": "anything", "definition": "[random(250..380#10),random(40..75#5)]"}, "scenario1": {"description": "", "name": "scenario1", "group": "Unnamed group", "templateType": "anything", "definition": "[\"A poll to determine which candidate is ahead in a two candidate election surveys\",\"A random sample of\"]\n\n"}, "se": {"description": "", "name": "se", "group": "Ungrouped variables", "templateType": "anything", "definition": "precround(sqrt((p_hat*(1-p_hat))/n1[Index]),4)"}, "scenario3": {"description": "", "name": "scenario3", "group": "Unnamed group", "templateType": "anything", "definition": "[\"of the voters surveyed intend to vote for candidate A. Calculate a\" , \"businesses had more than 15 employees. Calculate a\"]"}, "Index": {"description": "", "name": "Index", "group": "Ungrouped variables", "templateType": "anything", "definition": "random(0,1)"}, "alpha": {"description": "", "name": "alpha", "group": "Ungrouped variables", "templateType": "anything", "definition": "(100-percentage)/200"}, "scenario4": {"description": "", "name": "scenario4", "group": "Unnamed group", "templateType": "anything", "definition": "[\"confidence interval for the proportion of voters who intend on voting for candidate A.\", \"confidence interval for the proportion of businesses in the city that have more than 15 employees.\"]"}}, "rulesets": {}, "parts": [{"unitTests": [], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill", "showFeedbackIcon": true, "sortAnswers": false, "variableReplacements": [], "prompt": "The estimate for the population proportion $\\hat{p}=$ [[0]]
\nThe estimate for the standard error of the sample proportion = [[1]]
\n", "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "marks": 0, "gaps": [{"unitTests": [], "showCorrectAnswer": true, "showPrecisionHint": true, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "type": "numberentry", "minValue": "precround(p_hat,4)", "precisionType": "dp", "showFeedbackIcon": true, "variableReplacements": [], "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "extendBaseMarkingAlgorithm": true, "marks": 1, "customMarkingAlgorithm": "", "strictPrecision": true, "correctAnswerFraction": false, "precision": "4", "precisionPartialCredit": 0, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "precround(p_hat,4)", "allowFractions": false, "correctAnswerStyle": "plain"}, {"unitTests": [], "showCorrectAnswer": true, "showPrecisionHint": true, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "type": "numberentry", "minValue": "se", "precisionType": "dp", "showFeedbackIcon": true, "variableReplacements": [], "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "extendBaseMarkingAlgorithm": true, "marks": 1, "customMarkingAlgorithm": "", "strictPrecision": false, "correctAnswerFraction": false, "precision": "4", "precisionPartialCredit": 0, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "se", "allowFractions": false, "correctAnswerStyle": "plain"}], "customMarkingAlgorithm": ""}, {"unitTests": [], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill", "showFeedbackIcon": true, "sortAnswers": false, "variableReplacements": [{"part": "p0g0", "must_go_first": false, "variable": "p_hat"}, {"part": "p0g1", "must_go_first": false, "variable": "se"}], "prompt": "Lower limit = [[0]]
\nUpper limit = [[1]]
", "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "marks": 0, "gaps": [{"unitTests": [], "showCorrectAnswer": true, "showPrecisionHint": true, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "type": "numberentry", "minValue": "lower", "precisionType": "dp", "showFeedbackIcon": true, "variableReplacements": [{"part": "p0g0", "must_go_first": false, "variable": "p_hat"}, {"part": "p0g1", "must_go_first": false, "variable": "se"}], "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "extendBaseMarkingAlgorithm": true, "marks": 1, "customMarkingAlgorithm": "", "strictPrecision": false, "correctAnswerFraction": false, "precision": "2", "precisionPartialCredit": 0, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "lower", "allowFractions": false, "correctAnswerStyle": "plain"}, {"unitTests": [], "showCorrectAnswer": true, "showPrecisionHint": true, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "type": "numberentry", "minValue": "upper", "precisionType": "dp", "showFeedbackIcon": true, "variableReplacements": [{"part": "p0g0", "must_go_first": false, "variable": "p_hat"}, {"part": "p0g1", "must_go_first": false, "variable": "se"}], "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "extendBaseMarkingAlgorithm": true, "marks": 1, "customMarkingAlgorithm": "", "strictPrecision": false, "correctAnswerFraction": false, "precision": "2", "precisionPartialCredit": 0, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "upper", "allowFractions": false, "correctAnswerStyle": "plain"}], "customMarkingAlgorithm": ""}], "statement": "{scenario1[Index]} {n1[Index]} {scenario2[Index]} {prop1[Index]} {scenario3[Index]} {percentage}% {scenario4[Index]}
\n", "extensions": ["stats"], "variable_groups": [{"variables": ["scenario1", "scenario2", "prop1", "scenario3", "p_hat", "n1", "scenario4", "alpha2"], "name": "Unnamed group"}], "type": "question", "contributors": [{"name": "Clodagh Carroll", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/384/"}, {"name": "Catherine Palmer", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/423/"}]}]}], "contributors": [{"name": "Clodagh Carroll", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/384/"}, {"name": "Catherine Palmer", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/423/"}]}