Two-Mean Difference Confidence Interval Calculator
When two independent groups are compared, answering "are the means different?" with a p-value alone hides both how large the difference is and how precise the estimate is. A confidence interval for the difference in means delivers both at once: the direction of the difference, its size, and its margin of uncertainty appear on a single line.
This calculator accepts raw data or summary statistics (n, x̄, s) and builds an interval for the difference (x̄₁ − x̄₂) by two methods: the pooled method, which assumes equal variances, and the Welch method, which does not. With the automatic option, the variance ratio decides which method is appropriate. If the interval contains zero, the calculator states plainly that the difference between the means is not statistically significant; with raw data it also draws a box plot of the two groups.
Confidence Interval for the Difference of Two Means
Difference: d = x̄₁ − x̄₂ Pooled variance: sp² = [(n₁−1)s₁² + (n₂−1)s₂²] / (n₁ + n₂ − 2) Pooled SE: SE = sp · √(1/n₁ + 1/n₂), df = n₁ + n₂ − 2 Welch SE: SE = √( s₁²/n₁ + s₂²/n₂ ) Welch df: df = (s₁²/n₁ + s₂²/n₂)² / [ (s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1) ] Confidence interval: CI = d ± t(1−α/2; df) · SE Effect size: d_Cohen = (x̄₁ − x̄₂) / sp Decision: if 0 ∈ CI, the difference is not significant
The Welch degrees of freedom are usually not a whole number; the t distribution is defined for fractional degrees of freedom as well, and both SPSS and R report the same fractional value.
How to Calculate
- Choose the input format: paste the raw data of the two groups, or enter n, x̄, and s for each group.
- In raw-data mode, put each group in its own box; the groups may be of different sizes.
- Set the variance approach: if you are unsure, leave it on "Automatic", which switches to Welch when the variance ratio exceeds 2.
- Choose the confidence level; 95% is the standard choice in academic reporting.
- Check whether the resulting confidence interval contains zero: if it does, the difference is not significant.
- Use the box plot to inspect the spread and the outliers of the groups, then copy the reporting line into your write-up.
Worked Examples
Comparing the scores of two classes with raw data
The mean of group 1 is 83.60 (s = 4.09) and the mean of group 2 is 74.50 (s = 3.69); the difference is 9.100. Because the variance ratio is 1.228, the pooled variance is used: with a standard error of 1.7413, df = 18, and a critical t of 2.1009, the 95% confidence interval is [5.442; 12.758]. The interval does not contain zero, so the difference is significant (t = 5.2259; p < 0.001; d = 2.337).
95% confidence interval for the difference in means: [5.442; 12.758] · Difference in means (x̄₁ − x̄₂): 9.100 · Does the interval contain zero?: No — the difference is significant
A case where the interval contains zero
In two groups of 25, the means are 52.40 and 49.90; the difference is 2.500. With a pooled standard error of 2.8580, df = 48, and a critical t of 2.0106, the 95% confidence interval is [-3.246; 8.246]. Because the interval contains zero, the difference is not statistically significant (t = 0.8747; p = 0.386).
95% confidence interval for the difference in means: [-3.246; 8.246] · Difference in means (x̄₁ − x̄₂): 2.500 · Does the interval contain zero?: Yes — the difference is not significant
Welch when the variances differ
The variance ratio of 5.444 exceeds 2, so the automatic choice switches to the Welch method: with a standard error of 5.4836, an adjusted df = 19.73, and a critical t of 2.0878, the 95% confidence interval is [0.751; 23.649]. On the same data, the pooled method would have given [3.985; 20.415]. Because the interval stays just above zero the difference is significant (p = 0.038), but the closeness of the lower bound to zero shows that the estimate is weak.
95% confidence interval for the difference in means: [0.751; 23.649] · Difference in means (x̄₁ − x̄₂): 12.200 · Does the interval contain zero?: No — the difference is significant