t, Chi-Squared and F Distributions
The three sampling distributions behind inference: definitions, degrees of freedom and interrelations.
Assumes you know
t, Chi-Squared and F Distributions
Intuition first
These three exist because of one practical problem: you almost never know the population standard deviation .
The CLT says is standard normal. But you have to estimate from the same sample, and that estimate is itself random. Substituting for introduces extra variability, so the ratio has heavier tails than a normal. That heavier-tailed distribution is Student's t.
The chi-squared is what the sample variance follows, which is why it appears whenever variances or counts are being tested. And the F is a ratio of two chi-squareds, which is what you need when comparing two variances — or, equivalently, when comparing explained to unexplained variation, which is ANOVA.
All three are built from normal samples, and all three are relatives of the gamma.
Chi-squared
Sum of squared independent standard normals:
It is , which immediately gives those moments from the gamma formulas and .
| Symbol | Meaning | Read aloud |
|---|---|---|
| k or ν | Degrees of freedom | nu |
| χ²ₖ | Chi-squared with k degrees of freedom | chi squared k |
| s² | Sample variance with divisor n − 1 | s squared |
| tₙ₋₁ | t distribution with n − 1 degrees of freedom | t n minus one |
| F(d₁, d₂) | F with numerator and denominator degrees of freedom | F d one d two |
The sample variance
Why n − 1 degrees of freedom, and why s² divides by n − 1Advanced
The deviations satisfy one exact linear constraint:
So knowing of the deviations determines the last one. There are only freely varying quantities, hence degrees of freedom.
That constraint is also why divides by rather than . Consider the naive estimator . Expand about the true mean :
Take expectations term by term:
using . So dividing by gives
— biased downward, because deviations are measured from , which sits closer to the data than does. Dividing by corrects exactly this, giving . This is Bessel's correction.
Student's t
In practice:
| critical (95%, two-sided) | Normal | |
|---|---|---|
| 5 | 2.571 | 1.960 |
| 10 | 2.228 | 1.960 |
| 30 | 2.042 | 1.960 |
| 100 | 1.984 | 1.960 |
| 1.960 | 1.960 |
The F distribution
Ratio of two independent chi-squareds, each divided by its degrees of freedom:
Used to compare two variances, and — because ANOVA decomposes total variation into between-group and within-group sums of squares — to compare several group means at once.
Two useful facts:
Solved problem 1 · A t-interval, and why the multiplier matters
A sample of 12 measurements has and . Construct a 95% confidence interval for , then compare with what the normal multiplier would give.
Step 1 — degrees of freedom and multiplier
The two-sided 95% critical value is .
Step 2 — standard error
Step 3 — margin of error
Step 4 — the interval
Step 5 — compare with the normal multiplier
Width against the correct — about 11% too narrow. An interval claiming 95% coverage would actually cover roughly 92% of the time.
Answer
using . Using understates the width by 11% and overstates confidence.
Solved problem 2 · A chi-squared interval for a variance
Using the same sample (, ), construct a 95% confidence interval for .
Step 1 — the pivotal quantity
Step 2 — critical values, which are asymmetric
Unlike and , these are not symmetric — the chi-squared distribution is right-skewed.
Step 3 — invert the inequality
From , taking reciprocals reverses the order:
Step 4 — substitute
Taking square roots for the standard deviation:
Step 5 — note how wide this is
The point estimate is , and the interval runs from to — the upper end is 2.4 times the lower. Variance is estimated far less precisely than a mean at the same sample size, which is why "the variance is roughly stable" is a much weaker claim than it sounds with .
Answer
, so . Note the asymmetry: the interval extends much further above than below it.
import numpy as np
from scipy import stats
# t vs normal critical values.
print(f"{'df':>5} {'t (95%)':>8} {'z':>6} {'% wider':>8}")
for df in (5, 10, 11, 30, 100, 1000):
t = stats.t.ppf(0.975, df)
print(f"{df:5d} {t:8.4f} {1.96:6.3f} {100*(t/1.959964 - 1):7.1f}%")
# Worked example 1.
n, xbar, s = 12, 48.2, 3.6
se = s / np.sqrt(n)
tcrit = stats.t.ppf(0.975, n - 1)
print(f"\nt interval ({xbar - tcrit*se:.3f}, {xbar + tcrit*se:.3f}) width {2*tcrit*se:.3f}")
print(f"z interval ({xbar - 1.96*se:.3f}, {xbar + 1.96*se:.3f}) width {2*1.96*se:.3f}")
# Worked example 2: chi-squared interval for the variance.
lo = (n-1) * s**2 / stats.chi2.ppf(0.975, n-1)
hi = (n-1) * s**2 / stats.chi2.ppf(0.025, n-1)
print(f"\nvariance interval ({lo:.3f}, {hi:.3f}) sigma ({np.sqrt(lo):.3f}, {np.sqrt(hi):.3f})")
# Verify the sampling distributions by simulation.
rng = np.random.default_rng(0)
N, mu, sigma = 12, 50.0, 4.0
samples = rng.normal(mu, sigma, size=(200_000, N))
s2 = samples.var(axis=1, ddof=1)
chi = (N - 1) * s2 / sigma**2
t_stat = (samples.mean(axis=1) - mu) / (np.sqrt(s2) / np.sqrt(N))
print(f"\n(n-1)s²/σ²: mean {chi.mean():.3f} (theory {N-1}) var {chi.var():.3f} (theory {2*(N-1)})")
print(f"t statistic: var {t_stat.var():.4f} theory k/(k-2) = {(N-1)/(N-3):.4f}")
# F(1, d) = t_d squared.
print(f"\nF(1,10) 95th pct {stats.f.ppf(0.95, 1, 10):.4f} "
f"t_10 97.5th pct squared {stats.t.ppf(0.975, 10)**2:.4f}")The last two blocks are the checks worth running: the simulated -statistic variance matches rather than 1, and really is .
Exercise 1
Why does a interval get wider as the sample gets smaller, beyond the effect?
Show solutionHide solution
Two separate effects compound.
The standard error grows. increases as falls — the familiar effect.
The multiplier also grows. With fewer observations, is a worse estimate of . The distribution accounts for that extra uncertainty with heavier tails, so the critical value rises: at , at , at , at .
Going from to , the SE grows by a factor of and the multiplier by , so the interval widens by about rather than .
The intuition: with a small sample you are uncertain about the mean and uncertain about how uncertain you are. The distribution prices in the second-order uncertainty, which a normal interval ignores.
Exercise 2
A sample of 20 gives . Test against at the 5% level.
Show solutionHide solution
Test statistic:
Under this is . The one-sided 5% critical value is
Since , do not reject at the 5% level.
The p-value is — suggestive but above 0.05.
Worth noting how weak this test is. The sample variance is 50% larger than the hypothesised value and still not significant at 5%, because variance estimates are so noisy: , so a standard deviation of about 6.2 on a statistic with mean 19. Detecting moderate changes in variance requires substantially larger samples than detecting comparable changes in a mean.