From scattered misses to one number
Picture throwing darts at a bullseye. Some land left, some right, some short, some long — the misses scatter around the center. If you square each miss (so a left miss and a right miss both count as positive) and add all the squares together, you get one number that says "how much total scatter happened." The chi-squared distribution is simply the pattern that single summed-up-squared-scatter number follows when the misses are random.
Each standard normal $Z$ is one "miss" measured in standard-deviation units: centered at $0$ with a spread of $1$. Square it and you get $Z^2$, which can never be negative. Add up $k$ independent squared misses, $X = Z_1^2 + Z_2^2 + \dots + Z_k^2$, and that sum follows a chi-squared distribution with $k$ degrees of freedom, written $X\sim\chi^2_k$. The number $k$ just counts how many squared normals you stacked. Two facts fall straight out: the average of $X$ is exactly $k$ (each $Z^2$ averages $1$), and its variance is $2k$. So for $k=5$ you expect the total to hover near $5$, give or take about $\sqrt{10}\approx3.2$.
The exact density is $f(x;k)=\dfrac{x^{k/2-1}e^{-x/2}}{2^{k/2}\,\Gamma(k/2)}$ for $x>0$ — a special case of the Gamma family, since $\chi^2_k=\text{Gamma}(k/2,\,2)$. Because $X$ is a sum of independent identical pieces, the Central Limit Theorem takes over: for large $k$, $(\chi^2_k-k)/\sqrt{2k}\to N(0,1)$, so the lopsided curve straightens into a bell. In the simulation, the $k$ slider sets how many squared normals you add (it pushes the peak rightward and widens it), while the query slider $x$ marks a cutoff so the card reports the right-tail probability $P(X>x)$ — exactly the p-value a chi-squared test returns.
Set $k=1$ and watch the curve spike against the left wall — a single squared normal is usually small but occasionally huge. Then drag $k$ up to $30$ and open the "df Comparison" tab to see the shape march rightward and turn bell-like. Finally switch to "Live Sampling," press Play, and watch a histogram of real summed-squared-normals pile onto the theoretical curve while the sample mean closes in on $k$.
Chi-Squared Distribution — Helmert 1875 / Pearson 1900
If $Z_1,...,Z_k\overset{iid}{\sim}N(0,1)$, then $X=\sum_{i=1}^k Z_i^2\sim\chi^2_k$
$$\boxed{f(x;k)=\frac{x^{k/2-1}e^{-x/2}}{2^{k/2}\Gamma(k/2)},\quad x>0}$$
$E[X]=k,\quad\text{Var}(X)=2k,\quad\text{Mode}=\max(k-2,0)$
| k | Mean | Variance | Shape |
|---|---|---|---|
| 1 | 1 | 2 | Heavily right-skewed; spike at 0 |
| 2 | 2 | 4 | Exponential shape |
| 5 | 5 | 10 | Right-skewed, unimodal |
| 30 | 30 | 60 | Approximately normal (CLT) |
$\chi^2_k=\text{Gamma}(k/2,2)$. Sum of independent chi-squareds: $\chi^2_m+\chi^2_n=\chi^2_{m+n}$. As $k\to\infty$: by CLT, $\chi^2_k\approx N(k,2k)$. The standardized form: $(\chi^2_k-k)/\sqrt{2k}\to N(0,1)$. Square of a standard normal: $Z^2\sim\chi^2_1$.
Pearson goodness-of-fit test (§4 of the chi-squared test topic). Variance estimation: $(n-1)S^2/\sigma^2\sim\chi^2_{n-1}$. Confidence interval for variance: $\left[\frac{(n-1)S^2}{\chi^2_{n-1,\alpha/2}},\frac{(n-1)S^2}{\chi^2_{n-1,1-\alpha/2}}\right]$. The F-distribution: $F_{m,n}=(\chi^2_m/m)/(\chi^2_n/n)$.
95% CI for population variance: n=20, s²=4.2. We need $\chi^2_{19,0.025}=32.85$ and $\chi^2_{19,0.975}=8.91$.
$$CI=\left[\frac{19\times4.2}{32.85},\frac{19\times4.2}{8.91}\right]=[2.43,\;8.95]$$
"Chi-squared distribution can be negative."
Chi-squared is a sum of SQUARED standard normals — it's always non-negative. Domain is [0,∞). This is why chi-squared tests are always right-tailed: large values mean large discrepancy from expected. Small values (near 0) just mean excellent agreement.
📖 Hogg, McKean & Craig — Ch. 4.4
Wrong df in variance CI: using n instead of n-1
✅ $(n-1)S^2/\sigma^2\sim\chi^2_{n-1}$. One df lost because the sample mean was estimated. The CI uses $\chi^2_{n-1}$ critical values, not $\chi^2_n$.
🔍 Using chi2(n) instead of chi2(n-1) for variance inference.
Assuming chi-squared CI for variance is symmetric
✅ The chi-squared CI is asymmetric: $[(n-1)s^2/\chi^2_{upper}, (n-1)s^2/\chi^2_{lower}]$. The lower bound uses the UPPER chi-squared quantile and vice versa. Swapping them gives a CI entirely above or below the true value.
🔍 Mixing up which chi-squared quantile goes in numerator vs denominator.