Welch's test: it is not a replacement for the T-test

smatrosov3 Apr 2025

Problem

An analyst runs a two-sample comparison of means and sees the equal_var flag in scipy.stats.ttest_ind. The sample variances always differ, so switching to Welch's test looks safe. The real question is different: does the treatment change the population variance? A wrong choice either inflates the type I error or costs power.

Example from the article: a 700/300 split where the larger group has a standard deviation of 2 and the smaller one 20. The t-test then rejects a true null in 19.3% of simulated A/A runs instead of 5%.

Solution in brief

With large samples and a 50/50 split the standard t-test already keeps the type I error, so Welch's test is not needed. Welch's test helps only with an uneven split, or with small samples where the treatment changes the variance but not the mean. Do not pre-test variances and do not use Welch by default. Decide at the design stage and check both error types by simulation on your own data.

Questions this case answers
  • How to choose between a pooled-variance and an unequal-variance two-sample mean test when the treatment may change the spread of the metric
  • How to verify by A/A simulation that a two-sample test keeps its type I error under unequal variances and unbalanced groups, and what it costs in power
  • How to decide between Student's t-test and Welch's test for an A/B experiment?
  • How to tell when unequal variances really inflate the type I error of the t-test?

Tools and methods

  • Student's t-test (equal_var=True) — pools the sample variances; default for balanced, large samples.
  • Welch's test (equal_var=False) — keeps unequal variances and lowers the degrees of freedom.
  • A/A simulation (Monte Carlo) — repeats about 10k tests on resampled data to estimate type I error and power.
  • SciPy, statsmodels — ttest_ind, Wilson interval (proportion_confint).
Continue reading — it's free

Google or a one-time email code. No password.