Chip Foundry Services Request Assessment

Two-Sample T-Test

A two-sample t-test compares the means of two independent groups. Its central question is whether the observed mean difference is large relative to the uncertainty expected from sampling. For unequal group variances or unequal sample sizes, Welch's test is a reliable default; it does not require the two population variances to be equal.

Welch's two-sample test

For group $i$, let $n_i$ be the sample size, $\bar{x}_i$ the sample mean, and $s_i$ the sample standard deviation. To test a hypothesized difference $\Delta_0$ (usually zero), calculate:

$$t = \frac{(\bar{x}_1-\bar{x}_2)-\Delta_0}{\sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}}$$

Welch's approximate degrees of freedom are:

$$\nu = \frac{\left(\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}\right)^2}{\frac{\left(s_1^2/n_1\right)^2}{n_1-1} + \frac{\left(s_2^2/n_2\right)^2}{n_2-1}}$$

Compare $|t|$ with a $t$ distribution having $\nu$ degrees of freedom. For a two-sided test, $p=2P(T_\nu\ge |t|)$. The matching confidence interval for the population mean difference is:

$$(\bar{x}_1-\bar{x}_2) \pm t_{1-\alpha/2,\nu} \sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}$$

Worked example

Suppose group 1 has $n_1=25$, mean $10$, and standard deviation $2$. Group 2 has $n_2=16$, mean $12$, and standard deviation $3$. Then the standard error is $\sqrt{2^2/25+3^2/16}=0.85$, so the test statistic for $\Delta_0=0$ is $t=(10-12)/0.85\approx-2.353$. Welch's degrees of freedom are $\nu\approx23.556$. The negative sign records that group 1's mean is lower than group 2's. It does not by itself determine significance; use the two-sided p-value or confidence interval.

When to use the pooled form

The classical pooled test assumes equal population variances and combines the two sample variances:

$$s_p^2 = \frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}, \qquad t = \frac{(\bar{x}_1-\bar{x}_2)-\Delta_0}{s_p\sqrt{1/n_1+1/n_2}}, \qquad \nu=n_1+n_2-2$$

For the example above, pooling gives $s_p^2\approx5.923$, $t\approx-2.567$, and $\nu=39$, different from Welch's result. The formulas differ because the pooled version assumes equal population variances. Use it when that assumption is supported by the design or strong prior knowledge, not merely because a variance pretest failed to find a difference.

Assumptions and interpretation

  • The two groups contain independent observations. If measurements are paired or repeated on the same unit, analyze within-unit differences with a paired t-test instead.
  • Each group's data should not contain severe outliers. With small samples, inference also depends more strongly on the groups' distributions being reasonably close to normal.
  • The result tests a difference in means, not whether the difference is large enough to matter in practice. Report the estimated difference and confidence interval alongside the p-value.
  • State the subtraction order and whether the test is one-sided or two-sided before analyzing data.

Use Welch's formula for the usual independent-group comparison, unless equal variances are a defensible part of the study design. That keeps the reported uncertainty tied to the data actually collected.