Skip to content

Welch's t-test

Compare two independent means without assuming equal population variances. Work through the Welch standard error, fractional degrees of freedom and approximate confidence interval.

Welch's t-test compares the means of two independent populations without assuming that their population variances are equal. It divides the observed mean difference, after subtracting a hypothesised difference, by its estimated standard error and uses an approximate Student t reference distribution.
For a quant researcher, a higher average return in one group is only the start of the comparison. The size and variability of both samples determine how precisely that mean gap is estimated. Welch's method lets a smaller or noisier group contribute its own uncertainty instead of pooling the two variances under a common-variance assumption.

The denominator does the work

Let group A contain nAn_A observations and group B contain nBn_B. Write their sample means as xˉA,xˉB\bar x_A,\bar x_B, and their sample standard deviations as sA,sBs_A,s_B. Each sample variance uses its own denominator ng−1n_g-1.
For the null hypothesis H0:μA−μB=Δ0H_0:\mu_A-\mu_B=\Delta_0, define
Δ^=xˉA−xˉB,SE⁡^=sA2nA+sB2nB,tW=Δ^−Δ0SE⁡^.\widehat\Delta=\bar x_A-\bar x_B, \qquad \widehat{\operatorname{SE}}=\sqrt{\frac{s_A^2}{n_A}+\frac{s_B^2}{n_B}}, \qquad t_W=\frac{\widehat\Delta-\Delta_0}{\widehat{\operatorname{SE}}}.
The two variance contributions add because the groups are independent. The standard error has the same units as the observations; tWt_W is dimensionless.
The Welch–Satterthwaite degrees of freedom are
ν^=(sA2/nA+sB2/nB)2(sA2/nA)2nA−1+(sB2/nB)2nB−1.\widehat\nu= \frac{\left(s_A^2/n_A+s_B^2/n_B\right)^2} {\dfrac{(s_A^2/n_A)^2}{n_A-1}+\dfrac{(s_B^2/n_B)^2}{n_B-1}}.

Keep this value fractional when evaluating the t distribution numerically. It measures the uncertainty in the estimated variance of the contrast, rather than simply counting all observations minus two. If one variance contribution dominates, its group's residual degrees of freedom become especially influential.

For a predeclared two-sided alternative, the approximate p-value is
p=2 P ⁣(Tν^≥∣tW∣).p=2\,\mathbb P\!\left(T_{\widehat\nu}\ge\lvert t_W\rvert\right).
A matching approximate 100(1−α)%100(1-\alpha)\% confidence interval for μA−μB\mu_A-\mu_B is
Δ^ ± tν^,1−α/2 SE⁡^,\widehat\Delta\ \pm\ t_{\widehat\nu,1-\alpha/2}\,\widehat{\operatorname{SE}},
where tν,qt_{\nu,q} is the lower-CDF qq quantile. The degrees of freedom come from the data, and the reference is approximate even with independent normal observations. Welch inference does not inherit the exact finite-sample t guarantee of the equal-variance pooled normal model. NIST gives the two-sample standard error and reference construction.

A small comparison in basis points

Consider two hypothetical, independently sampled groups of same-horizon strategy returns under a fixed design:

  • Group A: 1,2,3,4,51,2,3,4,5 basis points.
  • Group B: −1,0,1,2-1,0,1,2 basis points.

For this teaching example, assume observations are independent within each group and between groups, with normal sampling in each population and unknown positive variances. These assumptions are stipulated, not inferred from nine observations. The rows are separate groups, not matched dates.

QuantityGroup AGroup B
Sample size54
Mean, bp30.5
Sample variance, bp squared5/25/25/35/3
Contribution to variance of the mean gap, bp squared1/21/25/125/12

Testing Δ0=0\Delta_0=0 against a two-sided alternative gives

Δ^=2.5 bp,SE⁡^=1112 bp≈0.957427 bp,\widehat\Delta=2.5\text{ bp},\qquad \widehat{\operatorname{SE}}=\sqrt{\frac{11}{12}}\text{ bp}\approx0.957427\text{ bp}, tW≈2.611165,ν^=36352≈6.980769,p≈0.034939.t_W\approx2.611165,\qquad \widehat\nu=\frac{363}{52}\approx6.980769,\qquad p\approx0.034939.

At a prespecified 5% significance level, this rejects a zero mean difference using the approximate Welch reference. With tν^,0.975≈2.365945t_{\widehat\nu,0.975}\approx2.365945, the corresponding 95% interval is

2.5±2.365945(0.957427)≈[0.234780, 4.765220] bp.2.5\pm2.365945(0.957427) \approx[0.234780,\ 4.765220]\text{ bp}.
Independent group returns in basis points: A has mean 3 and B has mean 0.5. The difference is 2.5 bp with SE 0.957 bp, df 6.981 and approximate 95% Welch interval 0.235 to 4.765 bp.
Independent group returns in basis points: A has mean 3 and B has mean 0.5. The difference is 2.5 bp with SE 0.957 bp, df 6.981 and approximate 95% Welch interval 0.235 to 4.765 bp.
Original synthetic example. Separate rows carry no pairing. The lower panel estimates the population mean difference using the stated sampling model and the approximate Welch reference.

The interval excludes zero, but spans a wide range of possible effect sizes. Statistical significance does not establish that the difference survives transaction costs, a new market regime or selection among many tested strategies. Nor is 0.0349390.034939 the probability that the null is true.

For the underlying interpretation, Confidence Intervals and Hypothesis Testing develops the one-sample t argument, connects tests with intervals and explains the significance trap. It has a public preview; the full lesson requires membership.

Choose the design before the formula

Unequal variances are allowed; dependence is a different problem. When two strategies run on the same dates, common market shocks can make their returns dependent. A paired t-test instead analyses matched differences when that design is appropriate. Serial dependence within either group also changes the sampling uncertainty. Welch's denominator supplies no correction for either kind of dependence.
A variance pretest is not an entry requirement. Welch can be selected in advance without first rejecting equality of variances. Failure to reject equal variances does not establish them, and choosing between pooled and Welch tests after an unadjusted preliminary test adds a selection step. R's two-sample t-test uses Welch by default. In SciPy's independent-samples test, Welch requires setting equal_var=False; its default assumes equal variances.
Normality matters most in short samples. For large independent samples with finite variances and suitable central-limit conditions, mean inference can be approximately justified beyond normal populations. Strong skew, extreme outliers and very small groups can make the approximation unreliable. More observations, a defensible sampling design and a method suited to the data matter more than a precise-looking fractional degree of freedom.

Sources

  • John A. Rice, Mathematical Statistics and Data Analysis, 3rd ed. (2007), §11.2.1, pp. 421–428: independent normal-sample contrasts and the unequal-variance t approximation. The numerical calculations here retain fractional degrees of freedom rather than using integer table lookup.
  • NIST/SEMATECH, “Two-Sample t-Test for Equal Means”: unpaired standard error, Welch–Satterthwaite reference and alternatives.
  • R stats, “Student's t-Test”: independent versus paired designs, hypothesised difference, Welch default and matching confidence interval.
  • SciPy, scipy.stats.ttest_ind: independent-sample testing, explicit unequal-variance option, test direction and interval output.
Last updated
  • welch
  • two sample inference
  • unequal variances
  • mean difference
  • student t
← Back to the glossaryBack to top ↑