// Numbas version: finer_feedback_settings {"name": "Confidence interval for variance", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Confidence interval for variance", "tags": [], "metadata": {"description": "
Finding the confidence interval at either 90%, 95% or 99% for the population variance of a sample. $\\chi^2$ tables are used. A single scenario is given.
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "A smartphone manufacturer claims that their new smartphone will last 24 hours on a full charge under normal usage with a standard deviation of 0.8 hours.
\nTesting 6 of these smartphones we see the following usage (in hours) until the battery dies:
\n{x} hours.
\nConstruct a {confl}% confidence interval for the standard deviation.
\nWe use the $\\chi^2$ tables to find the confidence interval for the population variance and then we can square root our lower and upper points of the interval to give us the confidence interval for the standard deviation.
\nThe formula for the confidence interval for the population variance is:
\n\\[\\frac{(n-1)s^2}{\\chi^2_{n-1;\\alpha/2}}\\le\\sigma^2\\le\\frac{(n-1)s^2}{\\chi^2_{n-1;1-\\alpha/2}}\\]
\n\nWe first calculate the sample variance using our formula:
\n\\[\\textrm{Sample Variance} = \\frac{1}{n-1}\\left(\\sum_{j=1}^{n}x_j^2 -n\\bar{x}^2\\right)=\\var{var}\\]
\n\n\nWe now need to find the critical values of the $\\chi^2$ distribution. Our degrees of freedom here are $n-1=\\var{n}-1=\\var{n-1}$.
\nOur confidence interval is $\\var{confl}\\%$ so our significance level is $\\alpha=\\var{alpha}$. Our critical values are then
\n\\[\\chi^2_{n-1;\\alpha/2}=\\chi^2_{\\var{n-1};\\var{alpha/2}}=\\var{chi_lower}\\]
\nand
\n\\[\\chi^2_{n-1;1-\\alpha/2}=\\chi^2_{\\var{n-1};\\var{1-alpha/2}}=\\var{chi_upper}\\]
\nHence, inputting all of these values into our formula for the confidence interval
\n\\[\\frac{(n-1)s^2}{\\chi^2_{n-1;\\alpha/2}}\\le\\sigma^2\\le\\frac{(n-1)s^2}{\\chi^2_{n-1;1-\\alpha/2}}\\]
\ngives the confidence intervals for the population variance $\\sigma^2$
\nLower value of the confidence interval $=\\;\\displaystyle \\var{var_lower}$.
\nUpper value of the confidence interval $=\\;\\displaystyle \\var{var_upper}$.
\nSquare rooting these values gives us the confidence interval for the population standard deviation $\\sigma$ (to 3 d.p.):
\n\\[(\\var{lower_round},\\var{upper_round})\\]
", "rulesets": {}, "extensions": ["stats"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"n": {"name": "n", "group": "Ungrouped variables", "definition": "6", "description": "", "templateType": "anything", "can_override": false}, "xbar": {"name": "xbar", "group": "Ungrouped variables", "definition": "sum(x)/n", "description": "", "templateType": "anything", "can_override": false}, "sd": {"name": "sd", "group": "Ungrouped variables", "definition": "stdev(x,true)", "description": "", "templateType": "anything", "can_override": false}, "chi_lower": {"name": "chi_lower", "group": "Ungrouped variables", "definition": "if(confl=90,11.07,if(confl=95,12.83,16.75))", "description": "", "templateType": "anything", "can_override": false}, "chi_upper": {"name": "chi_upper", "group": "Ungrouped variables", "definition": "if(confl=90,1.145,if(confl=95,0.8312,0.4117))", "description": "", "templateType": "anything", "can_override": false}, "var_lower": {"name": "var_lower", "group": "Ungrouped variables", "definition": "((n-1)*var)/chi_lower", "description": "", "templateType": "anything", "can_override": false}, "var": {"name": "var", "group": "Ungrouped variables", "definition": "sd^2", "description": "", "templateType": "anything", "can_override": false}, "var_upper": {"name": "var_upper", "group": "Ungrouped variables", "definition": "((n-1)*var)/chi_upper", "description": "", "templateType": "anything", "can_override": false}, "sd_lower": {"name": "sd_lower", "group": "Ungrouped variables", "definition": "sqrt(var_lower)", "description": "", "templateType": "anything", "can_override": false}, "sd_upper": {"name": "sd_upper", "group": "Ungrouped variables", "definition": "sqrt(var_upper)", "description": "", "templateType": "anything", "can_override": false}, "alpha": {"name": "alpha", "group": "Ungrouped variables", "definition": "if(confl=90,0.1,if(confl=95,0.05,0.01))", "description": "", "templateType": "anything", "can_override": false}, "confl": {"name": "confl", "group": "Ungrouped variables", "definition": "random(90,95,99)", "description": "", "templateType": "anything", "can_override": false}, "x": {"name": "x", "group": "Ungrouped variables", "definition": "repeat(random(230..240)*0.1,n)", "description": "", "templateType": "anything", "can_override": false}, "lower_round": {"name": "lower_round", "group": "Ungrouped variables", "definition": "precround(sd_lower,3)", "description": "", "templateType": "anything", "can_override": false}, "upper_round": {"name": "upper_round", "group": "Ungrouped variables", "definition": "precround(sd_upper,3)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["n", "xbar", "sd", "chi_lower", "chi_upper", "var_lower", "var", "var_upper", "sd_lower", "sd_upper", "alpha", "confl", "x", "lower_round", "upper_round"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Calculate a {confl}% confidence interval $(a,b)$ for the population standard deviation:
\n$a=\\;$[[0]] hours $b=\\;$[[1]] hours
\nEnter both to 1 decimal place.
", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "sd_lower-0.1", "maxValue": "sd_lower+0.1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": true, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "sd_upper-0.1", "maxValue": "sd_upper+0.1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": true, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Aamir Khan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4537/"}, {"name": "Laura Midgley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/18287/"}]}]}], "contributors": [{"name": "Aamir Khan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4537/"}, {"name": "Laura Midgley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/18287/"}]}