// Numbas version: exam_results_page_options {"name": "STAT7008: Independent two sample t-test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "STAT7008: Independent two sample t-test", "advice": "

We test the following hypothesis,

\n

$H_0:\\; \\mu_1=\\mu_2$ versus $H_1:\\; \\mu_1 \\neq \\mu_2$

\n

We find that the mean score of Group 1 is $\\overline{x}_1=\\var{mean1}$ with standard deviation $s_1=\\var{sd1}$ and the mean score of Group 2 is $\\overline{x}_2=\\var{mean2}$ with standard deviation $s_2=\\var{sd2}$.

\n

(All calculated to 3 decimal places.)

\n

Using the formula for the two-sample $t$-statistic as  shown above with $n_1=n_2=10$:

\n

The estimate of the pooled variance is calculated to be:

\n

\\[s^2=\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}= \\frac{\\var{n1-1}\\times \\var{sd1}^2+\\var{n2-1}\\times \\var{sd2}^2}{\\var{n1+n2-2}}=\\var{s^2}.\\] 

\n

Hence $s = \\sqrt{\\var{s^2}}=\\var{s}$ to 3 decimal places.

\n

We find that the t-statistic has value:

\n

\\begin{align}
T &= \\frac{(\\overline{x}_1-\\overline{x}_2)-(\\mu_1-\\mu_2)}{s\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}} \\\\
&= \\frac{(\\var{mean1}-\\var{mean2})-(0)}{\\var{s}\\sqrt{\\frac{1}{\\var{n1}}+\\frac{1}{\\var{n2}}}} \\\\
&= \\var{t_statistic}
\\end{align}

\n

Our test statistic is $|T|=\\var{abs(t_statistic)}$.

\n

Given that we have $n_1+n_2-2=18$ degrees of freedom, we look up this value on the T-distribution table for $t_{18}$

\n

\n

Hence we conclude that we {reject} the null hypothesis. There is {evidence_strength} evidence of a difference between the average scores of the two groups.

", "parts": [{"showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customMarkingAlgorithm": "", "steps": [{"unitTests": [], "marks": 0, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "type": "information", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "customMarkingAlgorithm": "", "prompt": "

The two-sample t-statistic for two independent sets of data where one set has $n_1$ data points and the other set $n_2$ data points is calculated as follows:

\n

\\[T = \\frac{(\\overline{x}_1-\\overline{x}_2)-(\\mu_1-\\mu_2)}{s\\times\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}\\;\\;\\;\\]

\n

where $\\overline{x}_1,\\;\\overline{x}_2$ are the sample means and 

\n

\\[s^2=\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}\\]

\n

where $s_1,\\;s_2$ are the sample standard deviations.

\n

Use the values you calculated to 3 decimal places in order to find $T$.

", "extendBaseMarkingAlgorithm": true}], "sortAnswers": false, "marks": 0, "stepsPenalty": 0, "variableReplacements": [], "showCorrectAnswer": true, "unitTests": [], "gaps": [{"mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "precisionType": "dp", "scripts": {}, "precisionPartialCredit": 0, "correctAnswerStyle": "plain", "mustBeReduced": false, "showFeedbackIcon": true, "correctAnswerFraction": false, "unitTests": [], "variableReplacements": [], "minValue": "mean1", "precisionMessage": "You have not given your answer to the correct precision.", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "", "maxValue": "mean1", "strictPrecision": false, "type": "numberentry", "precision": "3", "marks": 0.5, "showCorrectAnswer": true, "allowFractions": false}, {"mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "precisionType": "dp", "scripts": {}, "precisionPartialCredit": 0, "correctAnswerStyle": "plain", "mustBeReduced": false, "showFeedbackIcon": true, "correctAnswerFraction": false, "unitTests": [], "variableReplacements": [], "minValue": "sd1", "precisionMessage": "You have not given your answer to the correct precision.", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "", "maxValue": "sd1", "strictPrecision": false, "type": "numberentry", "precision": "3", "marks": 0.5, "showCorrectAnswer": true, "allowFractions": false}, {"mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "precisionType": "dp", "scripts": {}, "precisionPartialCredit": 0, "correctAnswerStyle": "plain", "mustBeReduced": false, "showFeedbackIcon": true, "correctAnswerFraction": false, "unitTests": [], "variableReplacements": [], "minValue": "mean2", "precisionMessage": "You have not given your answer to the correct precision.", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "", "maxValue": "mean2", "strictPrecision": false, "type": "numberentry", "precision": "3", "marks": 0.5, "showCorrectAnswer": true, "allowFractions": false}, {"mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "precisionType": "dp", "scripts": {}, "precisionPartialCredit": 0, "correctAnswerStyle": "plain", "mustBeReduced": false, "showFeedbackIcon": true, "correctAnswerFraction": false, "unitTests": [], "variableReplacements": [], "minValue": "sd2", "precisionMessage": "You have not given your answer to the correct precision.", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "", "maxValue": "sd2", "strictPrecision": false, "type": "numberentry", "precision": "3", "marks": 0.5, "showCorrectAnswer": true, "allowFractions": false}, {"mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "precisionType": "dp", "scripts": {}, "precisionPartialCredit": 0, "correctAnswerStyle": "plain", "mustBeReduced": false, "showFeedbackIcon": true, "correctAnswerFraction": false, "unitTests": [], "variableReplacements": [{"must_go_first": false, "variable": "mean1", "part": "p0g0"}, {"must_go_first": false, "variable": "sd1", "part": "p0g1"}, {"must_go_first": false, "variable": "mean2", "part": "p0g2"}, {"must_go_first": false, "variable": "sd2", "part": "p0g3"}], "minValue": "t_statistic", "precisionMessage": "

You have not given your answer to the correct precision.

", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "", "maxValue": "t_statistic", "strictPrecision": false, "type": "numberentry", "precision": "3", "marks": 1, "showCorrectAnswer": true, "allowFractions": false}], "prompt": "

Find the mean and standard deviations of the scores of the two groups. Round your answers to 3 decimal places.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
MeanStandard deviation
Group 1[[0]][[1]]
Group 2[[2]][[3]]
\n

Now find the two sample t-test statistic $T$ using the values you have just calculated and enter it here: [[4]]

", "type": "gapfill"}, {"showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customMarkingAlgorithm": "", "sortAnswers": false, "marks": 0, "variableReplacements": [], "showCorrectAnswer": true, "unitTests": [], "gaps": [{"mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "showFeedbackIcon": true, "correctAnswerStyle": "plain", "minValue": "tcrit-0.01", "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customMarkingAlgorithm": "", "correctAnswerFraction": false, "marks": 1, "mustBeReduced": false, "variableReplacements": [], "showCorrectAnswer": true, "unitTests": [], "allowFractions": false, "maxValue": "tcrit+0.01", "type": "numberentry"}], "prompt": "

The critical value is [[0]]

\n

", "type": "gapfill"}, {"displayType": "radiogroup", "choices": ["

We reject the null hypothesis at the $0.1\\%$ level

", "

We reject the null hypothesis at the $1\\%$ level.

", "

We reject the null hypothesis at the $5\\%$ level.

", "

We do not reject the null hypothesis but consider further investigation.

", "

We do not reject the null hypothesis.

"], "showFeedbackIcon": true, "variableReplacementStrategy": "alwaysreplace", "showCellAnswerState": true, "extendBaseMarkingAlgorithm": true, "scripts": {}, "customMarkingAlgorithm": "", "displayColumns": "1", "maxMarks": 0, "marks": 0, "minMarks": 0, "matrix": "decision_marking_matrix", "shuffleChoices": false, "variableReplacements": [{"must_go_first": false, "variable": "scenario", "part": "p0"}], "showCorrectAnswer": true, "unitTests": [], "prompt": "

What do you decide based on the above analysis?

", "type": "1_n_2"}], "metadata": {"description": "

Two sample t-test to see if there is a difference between scores on questions between two groups when the questions are asked in a different order.

", "licence": "Creative Commons Attribution 4.0 International"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "functions": {"pstdev": {"definition": "sqrt(len(l)/(len(l)-1))*stdev(l)", "type": "number", "parameters": [["l", "list"]], "language": "jme"}}, "preamble": {"css": "", "js": ""}, "ungrouped_variables": [], "extensions": ["stats"], "tags": [], "statement": "

An educational psychologist claimed that the order in which questions were asked affected the student’s ability to answer them correctly and hence their total score. In order to test this, $20$ students were randomly divided into two groups of $10$. The first group were given questions in increasing order of difficulty and the second group in decreasing order of difficulty. The ordered test scores obtained were:

\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
Group 1{r1[0]}{r1[1]}{r1[2]}{r1[3]}{r1[4]}{r1[5]}{r1[6]}{r1[7]}{r1[8]}{r1[9]}
Group 2{r2[0]}{r2[1]}{r2[2]}{r2[3]}{r2[4]}{r2[5]}{r2[6]}{r2[7]}{r2[8]}{r2[9]}
\n

Carry out a two-sample t-test to decide if there is evidence of a difference in the average test scores for the two sets of students.

", "variables": {"reject": {"name": "reject", "definition": "if(scenario<2,'do reject','do not reject')", "description": "

Do we reject the null hypothesis?

", "group": "Advice messages", "templateType": "anything"}, "sigma1": {"name": "sigma1", "definition": "random(8..10#0.2)", "description": "

Population standard deviation of sample 1

", "group": "Setup", "templateType": "anything"}, "p_value": {"name": "p_value", "definition": "ttest(abs(t_statistic),19,2)", "description": "

p-value corresponding to the t-statistic

", "group": "Stats", "templateType": "anything"}, "r2": {"name": "r2", "definition": "repeat(round(normalsample(mu2,sigma2)),n2)", "description": "

Sample 2

", "group": "Samples", "templateType": "anything"}, "decision_marking_matrix": {"name": "decision_marking_matrix", "definition": "[\n [1,0,0,0,0],\n [0,1,0,0,0],\n [0,0,1,0,0],\n [0,0,0,1,0],\n [0,0,0,0,1]\n][scenario]", "description": "

Marking matrix for the multiple choice questions

", "group": "Advice messages", "templateType": "anything"}, "sd2": {"name": "sd2", "definition": "precround(pstdev(r2),3)", "description": "

Sample standard deviation of sample 2

", "group": "Stats", "templateType": "anything"}, "mu1": {"name": "mu1", "definition": "random(55..75#0.5)", "description": "

Population mean of sample 1 (we'll generate samples from different distributions to produce different outcomes)

", "group": "Setup", "templateType": "anything"}, "n1": {"name": "n1", "definition": "10", "description": "

Size of sample 1

", "group": "Setup", "templateType": "anything"}, "p_value_range": {"name": "p_value_range", "definition": "['is less than $0.001$','lies between $0.001$ and $0.01$','lies between $0.01$ and $0.05$','lies between $0.05$ and $0.10$','is greater than $0.10$'][scenario]", "description": "

Describe where the p-value lies in relation to the critical values

", "group": "Advice messages", "templateType": "anything"}, "t90": {"name": "t90", "definition": "1.734", "description": "", "group": "Critical t-values", "templateType": "anything"}, "t99": {"name": "t99", "definition": "2.878", "description": "", "group": "Critical t-values", "templateType": "anything"}, "scenario": {"name": "scenario", "definition": "sum(map(abs(t_statistic)Which scenario are we in - how many critical values of the t distribution does t_statistic exceed?

", "group": "Advice messages", "templateType": "anything"}, "mu2": {"name": "mu2", "definition": "random(65..75#0.5)", "description": "

Population mean of sample 2

", "group": "Setup", "templateType": "anything"}, "s": {"name": "s", "definition": "precround(sqrt(((n1-1)*sd1^2+(n2-1)*sd2^2)/(n1+n2-2)),3)", "description": "

Used in the formula for the t statistic

", "group": "Stats", "templateType": "anything"}, "r1": {"name": "r1", "definition": "repeat(round(normalsample(mu1,sigma1)),n1)", "description": "

Sample 1

", "group": "Samples", "templateType": "anything"}, "sigma2": {"name": "sigma2", "definition": "random(8..10#0.2)", "description": "

Population standard deviation of sample 2

", "group": "Setup", "templateType": "anything"}, "sd1": {"name": "sd1", "definition": "precround(pstdev(r1),3)", "description": "

Sample standard deviation of sample 1

", "group": "Stats", "templateType": "anything"}, "n2": {"name": "n2", "definition": "10", "description": "

Size of sample 2

", "group": "Setup", "templateType": "anything"}, "tcrit": {"name": "tcrit", "definition": "studenttinv(0.975,18)", "description": "", "group": "Stats", "templateType": "anything"}, "t_statistic_range": {"name": "t_statistic_range", "definition": "['is greater than $\\\\var{t999}$','lies between $\\\\var{t99}$ and $\\\\var{t999}$','lies between $\\\\var{t95}$ and $\\\\var{t99}$','lies between $\\\\var{t90}$ and $\\\\var{t95}$','is less than $\\\\var{t90}$'][scenario]", "description": "

Describe where the t-statistic lies in relation to the critical values

", "group": "Advice messages", "templateType": "anything"}, "t_statistic": {"name": "t_statistic", "definition": "(mean1-mean2)*sqrt(n1*n2)/(s*sqrt(n1+n2))", "description": "", "group": "Stats", "templateType": "anything"}, "mean2": {"name": "mean2", "definition": "mean(r2)", "description": "

Sample mean of sample 1

", "group": "Stats", "templateType": "anything"}, "evidence_strength": {"name": "evidence_strength", "definition": "['very strong','strong','slight','no','no'][scenario]", "description": "

How much evidence is there against the null hypothesis?

", "group": "Advice messages", "templateType": "anything"}, "mean1": {"name": "mean1", "definition": "mean(r1)", "description": "

Sample mean of sample 1

", "group": "Stats", "templateType": "anything"}, "t95": {"name": "t95", "definition": "2.101", "description": "", "group": "Critical t-values", "templateType": "anything"}, "t999": {"name": "t999", "definition": "3.922", "description": "", "group": "Critical t-values", "templateType": "anything"}}, "variable_groups": [{"name": "Setup", "variables": ["n1", "n2", "mu1", "sigma1", "mu2", "sigma2"]}, {"name": "Samples", "variables": ["r1", "r2"]}, {"name": "Stats", "variables": ["mean1", "sd1", "mean2", "sd2", "s", "t_statistic", "p_value", "tcrit"]}, {"name": "Advice messages", "variables": ["scenario", "decision_marking_matrix", "reject", "evidence_strength", "t_statistic_range", "p_value_range"]}, {"name": "Critical t-values", "variables": ["t90", "t95", "t99", "t999"]}], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "type": "question", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Catherine Palmer", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/423/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Catherine Palmer", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/423/"}]}