t-Tests and Comparing Means
When you don't know the true spread, the t-distribution keeps your conclusions honest.
You almost never know σ
When we first standardized a value, we divided by the population standard deviation \(\sigma\). But here is the awkward truth about real data: you almost never know \(\sigma\). To know it you would already have had to measure the whole population — and if you had the whole population, you would not be taking a sample in the first place.
So we do the natural thing: we estimate \(\sigma\) from the sample itself, using the sample standard deviation \(s\). That small substitution has a surprisingly large consequence, and it is the whole reason the t-distribution exists.
Degrees of freedom control the shape
The t-distribution is not a single curve but a family, indexed by a number called the degrees of freedom (df). For a one-sample test, \(\text{df} = n - 1\).
With few degrees of freedom (small samples), \(s\) is a shaky estimate of \(\sigma\), so the tails are fat — extreme standardized values are more likely than the normal curve would suggest. As df grows, \(s\) settles down toward the true \(\sigma\), the tails thin out, and the t-curve becomes almost indistinguishable from the standard normal \(z\)-curve. By around df = 30 the two are already very close.
Reading the null distribution
A hypothesis test starts by assuming the null hypothesis is true — for a one-sample test, that the population mean really equals \(\mu_0\). Under that assumption the t statistic has a known distribution: the t-curve for its degrees of freedom. That curve is the null distribution.
The simulation below draws that null distribution. Move the degrees of freedom to watch the tails fatten and thin. Move the observed t to a value your data might produce, and the area in the tail beyond it gets shaded — that shaded area is the p-value. Switch between a one-sided and a two-sided test to see how the shading, and therefore the p-value, changes.
Comparing two groups
The most common question in practice is not 'does this mean equal a fixed number?' but 'do these two groups differ?' — treatment versus control, method A versus method B. The two-sample t-test answers it by standardizing the difference of the two sample means by its own standard error:
- Set up the hypotheses: null \(\mu = 50\) versus the two-sided alternative \(\mu \ne 50\).
- Estimated standard error of the mean: \(s/\sqrt{n} = 8/\sqrt{16} = 8/4 = 2\).
- Standardize: \(t = (\bar{x} - \mu_0)/(s/\sqrt{n}) = (53 - 50)/2 = 1.5\), with \(\text{df} = n - 1 = 15\).
- Compare against the null t-curve: for a two-sided test at the 0.05 level with df = 15, the cutoff is about 2.13. Our t = 1.5 does not reach it — the tail area (the p-value) is roughly 0.15.
Check your understanding
- You rarely know the population σ, so you estimate it with the sample standard deviation s.
- Substituting s for σ adds uncertainty, so the standardized statistic follows the t-distribution — a bell with heavier tails than the normal.
- The t-distribution is a family indexed by degrees of freedom (n − 1 for one sample); more df means thinner tails, approaching the standard normal z-curve.
- A one-sample t statistic is t = (x̄ − μ₀)/(s/√n); a two-sample t-test standardizes the difference of two group means by its own standard error.
- The p-value is the tail area under the null distribution — the chance of a result at least this extreme if the null were true, not the probability the null is true.