// Numbas version: exam_results_page_options {"name": "Two sample t-test: comparison of means", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Two sample t-test: comparison of means", "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-NonCommercial 4.0 International"}, "statement": "

It is believed that the hydrocarbon emissions of cars have decreased in the first decade of the new millenium. A study was conducted to compare the hydrocarbon emissions at idling speed, in parts per million (ppm), of cars built in 2000 and cars built in 2010. Fifteen cars from each year were randomly selected on the year of their production and their hydrocarbon emission levels were recorded.

\n

The data gathered is tabled below:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
2000 Model{r1[0]}{r1[1]}{r1[2]}{r1[3]}{r1[4]}{r1[5]}{r1[6]}{r1[7]}{r1[8]}{r1[9]}{r1[10]}{r1[11]}{r1[12]}{r1[13]}{r1[14]}
2010 Model{r2[0]}{r2[1]}{r2[2]}{r2[3]}{r2[4]}{r2[5]}{r2[6]}{r2[7]}{r2[8]}{r2[9]}{r2[10]}{r2[11]}{r2[12]}{r2[13]}{r2[14]}
\n

                   

", "advice": "

In this example we are comparing the means of two distict samples. 

\n

\\(H_0:\\) \\(\\mu_1=\\mu_2\\)    i.e. The mean emission rate is the same for both sets of cars.

\n

\\(H_1:\\) \\(\\mu_1>\\mu_2\\)    i.e.  The mean emission rate of the older set of cars is greater than the mean emission rate of the newer set of cars.

\n

For each sample we must evaluate the sample mean and the sample standard deviation.

\n

Recall when given a sample of size \\(n\\) :

\n

the formula for the sample mean:    \\(\\overline{x}=\\frac{\\sum {x}}{n}\\)

\n

 \\(\\overline{x_1}=\\var{sample_mean_1}\\)   and    \\(\\overline{x_2}=\\var{sample_mean_2}\\)

\n

the formula for the sample standard deviation:   \\(s=\\sqrt{\\frac{\\sum{(x-\\overline{x})^2}}{n-1}}\\)

\n

\\(s_1=\\var{sample_stdev_1}\\)     and     \\(s_2=\\var{sample_stdev_2}\\)

\n

We must evaluate the pooled sample standard deviation using the two sample standard deviartions \\(s_1\\) and \\(s_2\\) and the formula

\n

\\(s_p=\\sqrt{\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}}=\\sqrt{\\frac{14(\\var{sample_stdev_1})^2+14(\\var{sample_stdev_2})^2}{15+15-2}}=\\var{pooled_s}\\)

\n

The formula for the t-statistic:  

\n

\\(t=\\frac{\\overline{x_1}-\\overline{x_2}}{s_p\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}=\\frac{\\var{sample_mean_1}-\\var{sample_mean_2}}{\\var{pooled_s}\\sqrt{\\frac{1}{14}+\\frac{1}{14}}}=\\var{test_statistic}\\)

\n

The t-table value will be for a one-tailed test and will have \\(n_1+n_2-2=28\\) degrees of freedom. Because of the alternative hypothesis the t-value chosen will be positive. 

\n

\\[\\begin{array}{r|rrrr}&0.10&0.05&0.01\\\\\\hline28&\\var{t90}&\\var{t95}&\\var{t99}\\end{array}\\]

\n

Compare the test statistic with the t-table values and choose your conclusion.

\n

", "rulesets": {}, "extensions": ["stats"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"t99": {"name": "t99", "group": "Ungrouped variables", "definition": "2.467", "description": "", "templateType": "number", "can_override": false}, "sample_size": {"name": "sample_size", "group": "Ungrouped variables", "definition": "15", "description": "", "templateType": "number", "can_override": false}, "sigm1": {"name": "sigm1", "group": "Ungrouped variables", "definition": "random(5 .. 10#1)", "description": "", "templateType": "randrange", "can_override": false}, "t90": {"name": "t90", "group": "Ungrouped variables", "definition": "1.313", "description": "", "templateType": "number", "can_override": false}, "test_statistic": {"name": "test_statistic", "group": "Ungrouped variables", "definition": "precround((sample_mean_1-sample_mean_2)/(pooled_s*sqrt(2/15)),2)", "description": "

t

", "templateType": "anything", "can_override": false}, "r1": {"name": "r1", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sigm1)),sample_size)", "description": "", "templateType": "anything", "can_override": false}, "sample_stdev_2": {"name": "sample_stdev_2", "group": "Ungrouped variables", "definition": "precround(sqrt(15*stdev(r2)^2/14),2)", "description": "", "templateType": "anything", "can_override": false}, "pooled_s": {"name": "pooled_s", "group": "Ungrouped variables", "definition": "precround(sqrt((sample_stdev_1^2+sample_stdev_2^2)/2),2)", "description": "", "templateType": "anything", "can_override": false}, "k": {"name": "k", "group": "Ungrouped variables", "definition": "random(3 .. 6#1)", "description": "", "templateType": "randrange", "can_override": false}, "t95": {"name": "t95", "group": "Ungrouped variables", "definition": "1.701", "description": "", "templateType": "number", "can_override": false}, "sample_mean_2": {"name": "sample_mean_2", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "description": "", "templateType": "anything", "can_override": false}, "sample_stdev_1": {"name": "sample_stdev_1", "group": "Ungrouped variables", "definition": "precround(sqrt(15*stdev(r1)^2/14),2)", "description": "", "templateType": "anything", "can_override": false}, "mu1": {"name": "mu1", "group": "Ungrouped variables", "definition": "random(220 .. 240#1)", "description": "", "templateType": "randrange", "can_override": false}, "sample_mean_1": {"name": "sample_mean_1", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "description": "", "templateType": "anything", "can_override": false}, "r2": {"name": "r2", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sigm2)),sample_size)", "description": "", "templateType": "anything", "can_override": false}, "sigm2": {"name": "sigm2", "group": "Ungrouped variables", "definition": "random(4 .. 8#1)", "description": "", "templateType": "randrange", "can_override": false}, "mu2": {"name": "mu2", "group": "Ungrouped variables", "definition": "mu1-k", "description": "", "templateType": "anything", "can_override": false}, "atvalue": {"name": "atvalue", "group": "Ungrouped variables", "definition": "abs(test_statistic)", "description": "", "templateType": "anything", "can_override": false}, "v": {"name": "v", "group": "Ungrouped variables", "definition": "if(atvalue>=t99,[1,0,0,0],if(atvalue>=t95,[0,1,0,0],if(atvalue>=t90,[0,0,1,0],[0,0,0,1])))", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["r1", "sample_mean_1", "sample_stdev_1", "mu1", "sigm1", "test_statistic", "t95", "t99", "t90", "r2", "mu2", "sigm2", "sample_mean_2", "sample_stdev_2", "pooled_s", "sample_size", "k", "atvalue", "v"], "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": "

Input the sample mean for 2000 data: [[0]]

\n

Input the sample standard deviation for 2000 data: [[1]]

\n

Input the sample mean for 2010 data: [[3]]

\n

Input the sample standard deviation for 2010 data: [[4]]

\n

Enter the value for the test statistic: t = [[2]]

\n

", "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": "sample_mean_1", "maxValue": "sample_mean_1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "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": "sample_stdev_1", "maxValue": "sample_stdev_1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "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": [{"variable": "sample_mean_2", "part": "p0g0", "must_go_first": true}, {"variable": "sample_stdev_2", "part": "p0g1", "must_go_first": true}], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "test_statistic", "maxValue": "test_statistic", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "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": "sample_mean_2", "maxValue": "sample_mean_2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "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": "sample_stdev_2", "maxValue": "sample_stdev_2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "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}, {"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [{"variable": "", "part": "p0g2", "must_go_first": false}], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Having compared your test statistic with the table values for a one-tailed t-test with 28 degrees of freedom, select one of the following conclusions that best describes your conclusion.

", "minMarks": "3", "maxMarks": "3", "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": "1", "showCellAnswerState": true, "choices": ["

Reject the Null Hypothesis and conclude that mean hydrocarbon emission rate has decreased. 

", "

Reject the Null Hypothesis at the 5% significance level but accept the Null Hypothesis at the 1% significance level and conclude that mean hydrocarbon emission rate is the same for both models.

", "

Reject the Null Hypothesis at the 10% significance level but accept the Null Hypothesis at the 5% significance level and conclude that mean hydrocarbon emission rate is the same for both models.

", "

Accept the Null Hypothesis at the 10% significance level and conclude that mean hydrocarbon emission rate is the same for both models.

"], "matrix": "v"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Frank Doheny", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/789/"}]}]}], "contributors": [{"name": "Frank Doheny", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/789/"}]}