Two-Sample t-Test: A Worked Example Comparing Two Group Means
October 29, 2026
The two-sample t-test compares the average of two independent groups to see whether the difference is larger than what chance variation would produce. It is used to compare test scores under two teaching methods, recovery times under two treatments, or conversion rates of two web designs (using appropriate variants).
Suppose Group A (n = 30) scored a mean of 78 with a standard deviation of 10, and Group B (n = 30) scored a mean of 72 with a standard deviation of 12. The observed difference is 6 points. Is it statistically significant?
Skip the math and get your answer instantly:
Open the Standard Deviation Calculator →The Calculation (Welch's Version)
Welch's t-test does not assume equal variances. The standard error of the difference is √(s₁²/n₁ + s₂²/n₂) = √(100/30 + 144/30) = √(3.333 + 4.800) = √8.133 = 2.85. The test statistic is t = (78 − 72) ÷ 2.85 = 2.10. The degrees of freedom are estimated by the Welch–Satterthwaite formula: (3.333 + 4.8)² ÷ (3.333²/29 + 4.8²/29) = 66.15 ÷ (0.383 + 0.794) = 56.2. With about 56 degrees of freedom, a t of 2.10 corresponds to a two-sided p-value of about 0.040.
Since p < 0.05, the difference is statistically significant at the 5% level. The critical t value for 56 degrees of freedom at the 5% level is about 2.00.
| Quantity | Value |
|---|---|
| Mean difference | 6.0 |
| Standard error | 2.85 |
| t statistic | 2.10 |
| Degrees of freedom (Welch) | about 56 |
| Two-sided p-value | about 0.040 |
| 95% CI for the difference | 0.3 to 11.7 |
Confidence Interval and Effect Size
A 95% confidence interval for the difference is 6 ± 2.00 × 2.85 = 6 ± 5.7, or 0.3 to 11.7 points. The interval barely excludes zero, matching the borderline p-value; it also shows that the true difference might be small (0.3) or large (11.7). The effect size, Cohen's d, expresses the difference in standard deviation units: d = 6 ÷ pooled SD, where the pooled SD is √((10² + 12²) ÷ 2) = 11.05, so d = 0.54, a medium effect. Always report the difference with its interval and the effect size, not only the p-value.
Assumptions
Observations in each group should be independent; the groups should be independent of each other (for before-and-after measurements on the same people, use the paired t-test); and the data in each group should be roughly normal, though the test is fairly robust for moderate-to-large samples (n ≥ 30) thanks to the central limit theorem. Outliers can distort the means; check with plots. If data are strongly skewed with small samples, consider a nonparametric alternative such as the Mann-Whitney U test.
Practical Interpretation and Pitfalls
Statistical significance does not mean practical importance: a 6-point difference matters differently if the scale is 0 to 100 or 0 to 1,000. A p-value near 0.05 is fragile: a slightly different sample could flip the conclusion. Plan sample sizes in advance: to detect a medium effect (d = 0.5) with 80% power at the 5% level, you need about 64 per group. Avoid repeated testing and selective reporting. A well-designed randomized experiment allows a causal interpretation of the difference; observational comparisons may be confounded.
Frequently Asked Questions
What does a two-sample t-test do?
It tests whether the means of two independent groups differ by more than chance would produce.
What is Welch's t-test?
A version that does not assume equal variances in the two groups.
What is the standard error of a difference in means?
The square root of the sum of each group's variance divided by its sample size.
What sample size do I need for a medium effect?
About 64 per group for 80% power at the 5% level.
When should I use a paired t-test?
When the two measurements come from the same subjects or matched pairs.