What the two-sample t-test does
The two-sample t-test checks whether the means of two independent groups differ by more than chance would explain. You only need each group’s mean, standard deviation and size, for example from a published table or a spreadsheet summary.
The formulas
Welch’s t-test (the safer default, which does not assume equal variances):
t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂)
with the Welch–Satterthwaite degrees of freedom:
df = (s₁²/n₁ + s₂²/n₂)² ÷ [(s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)]
Student’s t-test pools the two variances, assuming they are equal, and uses df = n₁ + n₂ − 2.
The p-value comes from Student’s t distribution with those degrees of freedom.
Example
Group 1: mean 75, SD 10, n = 30. Group 2: mean 70, SD 12, n = 32.
- standard error: √(100/30 + 144/32) ≈ 2.80;
- t = 5 ÷ 2.80 ≈ 1.79, with about 59.2 degrees of freedom;
- two-tailed p ≈ 0.079: not significant at α = 0.05;
- 95% confidence interval of the difference: about −0.6 to 10.6, which includes 0;
- Cohen’s d ≈ 0.45, a small to medium effect.
Reading the result
- p below α: the difference is statistically significant; the data are unlikely if the true means were equal.
- p at or above α: the data are compatible with no difference. This does not prove the means are equal; the study may simply be too small.
- The confidence interval shows the plausible size of the difference, which matters more than the p-value alone.
One or two tails?
Use a two-tailed test unless you decided before seeing the data that only one direction matters. A one-tailed test halves the p-value, so choosing it after the fact inflates false positives.
Assumptions
- The two groups are independent. For before-and-after measurements on the same people, use the paired (one-sample) t-test on the differences.
- Each group’s values are roughly normal, or the samples are large enough (often 30 or more per group) for the central limit theorem to apply.
- For Student’s version, the variances are similar. Welch’s test works well in both cases, which is why many statisticians recommend it by default.
For strongly skewed data or small samples, a non-parametric test such as the Mann–Whitney U test is an alternative.