Understanding the two-sample t-test — concept and principle
A two-sample (independent) t-test checks whether two separate groups have different means, such as a treatment and a control group. The calculator reports Welch's t-test, which does not assume equal variances and is the recommended default, the classic pooled (Student) t-test, and Cohen's d as a measure of effect size.
How it is calculated
- Welch: t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂).
- Welch–Satterthwaite df: (v₁ + v₂)² ÷ [v₁²/(n₁ − 1) + v₂²/(n₂ − 1)], where v = s²/n. The df is usually not a whole number.
- Pooled variance: s_p² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] ÷ (n₁ + n₂ − 2); pooled t = (x̄₁ − x̄₂) ÷ √[s_p²(1/n₁ + 1/n₂)] with n₁ + n₂ − 2 df.
- Cohen's d = (x̄₁ − x̄₂) ÷ s_p.
All p-values are two-tailed.
The principle
The difference between two sample means has its own standard error, built from the variability and size of each group. The t statistic measures the observed difference in units of that standard error. The pooled test assumes both groups share one variance and combines them; Welch (1947) lets each group keep its own variance and adjusts the degrees of freedom, which keeps the error rate close to α even when variances and group sizes differ. When the sizes are equal, the two t values are identical and only the df differ.
Worked example
- Group A: 23, 25, 28, 30, 27, 26 (mean 26.5, variance 5.9). Group B: 20, 22, 24, 21, 23, 19 (mean 21.5, variance 3.5). n = 6 each.
- v₁ = 5.9 ÷ 6 = 0.98333, v₂ = 3.5 ÷ 6 = 0.58333; √(v₁ + v₂) = 1.25167.
- Welch t = 5 ÷ 1.25167 = 3.99467731.
- Welch df = 1.56667² ÷ (0.98333²/5 + 0.58333²/5) = 9.3880153; p = 0.0028808345.
- Pooled: s_p² = (5 × 5.9 + 5 × 3.5) ÷ 10 = 4.7; t = 5 ÷ √(4.7 × 1/3) = 3.99467731 with 10 df; p = 0.0025400514. Shown as 3.99467731 / 0.0025400514.
- Cohen's d = 5 ÷ √4.7 = 2.30632802.
How to read the result
Both tests give p < 0.01, so the difference of 5 units is very unlikely to be chance. Cohen (1988) suggested d ≈ 0.2 as small, 0.5 as medium and 0.8 as large; d ≈ 2.3 means the group means are more than two pooled standard deviations apart, a very large effect.
Common mistakes
- Using an independent test on paired data (same subjects before and after); use the paired t-test instead.
- Running a variance test first and then choosing pooled or Welch; simply use Welch.
Frequently asked questions
Why does Welch's df have decimals?
It is an approximation (Satterthwaite) that blends the two groups' information; the t distribution is defined for non-integer df too.
Why are Welch t and pooled t the same here?
With equal group sizes the two standard error formulas give the same value; only the degrees of freedom, and so the p-value, differ.
What if the data are not normal?
For small or skewed samples, the Mann–Whitney U test is a common non-parametric alternative.
Sources: Welch, B. L. (1947). The generalization of "Student's" problem when several different population variances are involved. Biometrika, 34, 28–35. · Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum.