t-test calculator
Paste the samples. The tool works out the means and standard deviations, the t statistic, the degrees of freedom and the p-value, one step at a time.
- Mean 1
- 70.9
- Mean 2
- 66.0
- t statistic
- 2.80
- Degrees of freedom
- 11
- p-value
- 0.0172
Show the working
H0: μ1 = μ2; H1: μ1 ≠ μ2.
x̄1 = 70.9, s1 = 3.18, n1 = 7; x̄2 = 66.0, s2 = 3.03, n2 = 6
Pooled variance sp² = [(n1 − 1)s1² + (n2 − 1)s2²] ÷ (n1 + n2 − 2) = 9.71
t = (x̄1 − x̄2) ÷ √[sp²(1/n1 + 1/n2)] = 2.80, with 11 degrees of freedom
p-value (two-tailed) = 0.0172; critical value at 5% = ±2.20
p = 0.0172 < 0.05, so there is evidence to reject H0 at the 5% level.
Answers are rounded to 3 significant figures, which is what IB papers ask for unless a question says otherwise.
How to do it by hand
- Write the hypotheses about the population means, for example H₀: μ₁ = μ₂ and H₁: μ₁ > μ₂, and decide whether the test is one- or two-tailed before you look at the data.
- Find each sample's mean and its unbiased standard deviation s (divide by n − 1).
- Two samples, pooled: sₚ² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] ÷ (n₁ + n₂ − 2) and t = (x̄₁ − x̄₂) ÷ √[sₚ²(1/n₁ + 1/n₂)] with n₁ + n₂ − 2 degrees of freedom. Paired: a one-sample test on the differences.
- Compare the p-value with the significance level and conclude in context.
Worked example
Two groups of students timed how long (in seconds) they could hold their breath. Group A: 41, 38, 45, 50, 36, 44. Group B: 35, 33, 40, 37, 31, 36, 34. Test at the 5% level whether group A's mean is greater, assuming equal variances.
Solution
H0: μ1 = μ2; H1: μ1 > μ2.
x̄1 = 42.3, s1 = 5.09, n1 = 6; x̄2 = 35.1, s2 = 2.91, n2 = 7
Pooled variance sp² = [(n1 − 1)s1² + (n2 − 1)s2²] ÷ (n1 + n2 − 2) = 16.4
t = (x̄1 − x̄2) ÷ √[sp²(1/n1 + 1/n2)] = 3.19, with 11 degrees of freedom
p-value (one-tailed) = 0.00428; critical value at 5% = 1.80
p = 0.00428 < 0.05, so there is evidence to reject H0 at the 5% level.
Answer: t = 3.19, df = 11, p = 0.00428
Every number in this example is worked out by the same code as the tool above, and the code is tested against independent results from Python's SciPy library.
Where you need it
| AA SL | Not in the syllabus |
|---|---|
| AA HL | Not in the syllabus |
| AI SL | The two-sample t-test. |
| AI HL | The two-sample t-test, plus the further tests in the HL syllabus. |
On your calculator
In the exam you use your own calculator, so practise it too. Our guides give the exact keystrokes for the Casio fx-CG50, TI-Nspire CX II and TI-84 Plus CE, with a worked example to check against:
Common mistakes
- Using σ (divide by n) instead of s (divide by n − 1) for the sample standard deviations.
- Doubling or halving the p-value wrongly: the two-tailed p-value is twice the one-tailed one.
- Treating paired data (the same people measured twice) as two independent samples. Test the differences instead.
- Choosing one- or two-tailed after seeing the data. The alternative hypothesis comes from the question.
Notes and practice
Questions students ask
When do I use a paired t-test?
When each value in one sample is matched with a value in the other, such as the same students before and after a revision course. Work with the differences, which removes the variation between students.
Pooled or not pooled?
Pooling assumes the two populations have the same variance; it is what the IB's two-sample t-test uses. Welch's version drops that assumption, and its degrees of freedom are usually not a whole number.
What does the p-value mean?
The probability, if H₀ were true, of getting a test statistic at least as extreme as yours. A small p-value means your data would be unusual under H₀.