physics2u
Tier
⌕ Search ⌘K
physics2u.com/vault/chi-squared-distribution-from-gaussians.html
Derivation

The Chi-Squared Distribution

D-123 Home PU-106 Threads chance Depends on The Central Limit Theorem
Statement

Let Z1, …, Zk be independent standard-normal variables, Zi ~ N(0, 1), and define Q = Σi=1k Zi2. Then Q follows the chi-squared distribution with k degrees of freedom, with probability density fQ(x) = xk/2 − 1 ex/2 ⁄ [2k/2 Γ(k/2)] for x > 0, mean E[Q] = k, and variance Var(Q) = 2k.

Why it matters

The chi-squared distribution is the exact sampling distribution of a sum of squared Gaussian fluctuations. It governs the estimated variance of any normally distributed measurement, underlies every least-squares goodness-of-fit test, and is the reference distribution against which experimental χ2 statistics are compared to accept or reject a model.

It also appears directly in physics: the kinetic energy of a classical particle in a heat bath is a sum of squared Gaussian velocity components, so the chi-squared distribution with k = 3 is the equilibrium energy distribution, and its mean k is exactly the equipartition theorem in disguise.

Assumptions
Each Zi is standard normal (zero mean, unit variance).A non-zero mean gives the noncentral chi-squared distribution; a variance σ2 ≠ 1 rescales Q by σ2 and shifts the density.
The Zi are mutually independent.Correlated components make the moment-generating function fail to factor, so the sum is no longer chi-squared; one must diagonalise the covariance first.
k is a fixed integer, not itself estimated from the data.If the k squared terms are residuals about parameters fitted from the same sample, each fitted parameter removes one degree of freedom, and the effective k drops below the naive count (Cochran's theorem).
The moment-generating function exists in a neighbourhood of t = 0.Without a strip of convergence the uniqueness theorem for MGFs cannot be invoked, and one must instead invert the characteristic function to identify the density.
Derivation
1
Y = Z2,   FY(y) = P(−√yZ ≤ √y) = 2Φ(√y) − 1
Start with a single component. The event Z2y is the symmetric interval, and Φ is the standard-normal CDF. A
2
fY(y) = dFY/dy = 2φ(√y) · 1⁄(2√y) = φ(√y) ⁄ √y
Differentiate the CDF; the chain rule supplies the Jacobian factor 1⁄(2√y) with φ = Φ′ the standard-normal density. A
3
fY(y) = (2π)−1/2 y−1/2 ey/2,   y > 0
Insert φ(u) = (2π)−1/2eu2/2 with u = √y. This is already the k = 1 chi-squared density. A
4
M1(t) = E[etY] = (2π)−1/20 y−1/2 ey(1/2 − t) dy
Form the moment-generating function of one squared normal. The integral converges only for t < 1/2, defining the strip of existence. B
5
0 y−1/2 eay dy = Γ(1/2) a−1/2 = √π a−1/2,   a = 1/2 − t
Evaluate with the Gamma integral ∫0ys−1eaydy = Γ(s)as at s = 1/2, using Γ(1/2) = √π. B
6
M1(t) = (2π)−1/2 √π (1/2 − t)−1/2 = (1 − 2t)−1/2
Collect the constants: (2π)−1/2√π = 2−1/2, and (1/2 − t)−1/2 = 21/2(1 − 2t)−1/2. A
7
MQ(t) = ∏i=1k M1(t) = (1 − 2t)k/2
The MGF of a sum of independent variables is the product of their MGFs; independence is exactly what licenses this factorisation. C
8
(1 − 2t)k/2 = (1 − θt)−α with α = k/2, θ = 2  ⇒  Q ~ Gamma(α, θ)
Match against the Gamma MGF (1 − θt)−α. Because the MGF exists on an open interval it determines the law uniquely, identifying the density. C
9
fQ(x) = xα−1 ex ⁄ [Γ(α) θα] = xk/2 − 1 ex/2 ⁄ [2k/2 Γ(k/2)]
Substitute α = k/2, θ = 2 into the standard Gamma density. This is the chi-squared density with k degrees of freedom. A
10
K(t) = ln MQ(t) = −(k/2) ln(1 − 2t)
Take the cumulant-generating function so that derivatives at t = 0 give the mean and variance directly. B
11
K′(t) = k ⁄ (1 − 2t),   E[Q] = K′(0) = k
The first cumulant is the mean. (Consistency check: E[Z2] = 1, summed k times.) A
12
K″(t) = 2k ⁄ (1 − 2t)2,   Var(Q) = K″(0) = 2k
The second cumulant is the variance. (Check: Var(Z2) = E[Z4] − 1 = 3 − 1 = 2, summed k times.) A
Result
fQ(x) = xk/2 − 1 ex/2 ⁄ [2k/2 Γ(k/2)],   x > 0,   E[Q] = k,   Var(Q) = 2k

Reading. A sum of k independent squared standard-normals is right-skewed, supported on the positive axis, and peaks near x = k − 2. Its centre of mass sits at k and its spread grows as √(2k); each extra degree of freedom adds one unit of expected value and two units of variance. The xk/2−1 factor controls the behaviour near the origin and the ex/2 factor the exponential tail.

Units check. Each Zi is dimensionless (a value divided by its own standard deviation), so Q and x are dimensionless. A density in x must carry dimension 1⁄x, and indeed fQ integrates to a pure number: ∫0 xk/2−1ex/2dx = 2k/2Γ(k/2), which cancels the normalisation exactly.

Limiting cases
  • k = 1: f(x) = (2πx)−1/2ex/2, which diverges as x−1/2 at the origin (integrably) — the density of a single squared Gaussian.
  • k = 2: f(x) = ½ex/2, an exponential with mean 2; equivalently the distribution of twice a Rayleigh-squared radius.
  • k = 3: f(x) = (x/2π)1/2ex/2 — the Maxwell–Boltzmann energy distribution with mean (3/2), the equipartition value.
  • k → ∞: by the central limit theorem the standardised variable (Qk)⁄√(2k) → N(0, 1); the skewness √(8/k) vanishes and the shape becomes symmetric.
Breaks when
  • Correlated components. If the Zi are dependent, MQ no longer factors as a product; the quadratic form ∑Zi2 then follows a weighted sum of independent chi-squares (eigenvalues of the covariance), not a single chi-squared.
  • Non-zero means. If Zi ~ Ni, 1) with μi ≠ 0, the result is the noncentral chi-squared with noncentrality λ = ∑μi2; the mean becomes k + λ and variance 2k + 4λ.
  • Estimated parameters. When the squared terms are residuals about p parameters fitted from the same data, the true degrees of freedom are kp, not k; using the naive count biases every goodness-of-fit inference.
  • Non-Gaussian heavy tails. If the underlying variables are not normal (e.g. Student-t with few degrees of freedom), the sum of squares has heavier tails than chi-squared and the density above is only an approximation that worsens in the tail.
Failure modes
  • Confusing k with sample size. Treating the degrees of freedom as the number of data points and forgetting the −1 (or −p) reduction when the mean or other parameters are estimated.
  • Assuming symmetry. Reading off a two-sided confidence interval as if chi-squared were symmetric about its mean; the density is right-skewed and the upper and lower tails differ.
  • Dropping the Jacobian. In the k = 1 transformation, writing fY(y) = φ(√y) and forgetting the 1⁄(2√y) factor, which loses the crucial y−1/2 singularity.
  • Using variance = k. Copying the mean as the variance; the correct variance is 2k because Var(Z2) = 2, not 1.
  • Squaring correlated residuals. Applying the result to fit residuals that share a fitted baseline and are therefore not independent, inflating the apparent number of degrees of freedom.
Discussion

The chi-squared law is the special case Gamma(k/2, 2) of the Gamma family, and this identification is more than bookkeeping: it means that a sum of two independent chi-squares with k1 and k2 degrees of freedom is again chi-squared with k1 + k2, exactly the additivity we exploited through the MGF product in step 7. Degrees of freedom add like independent squared coordinates — a purely geometric statement about orthogonal directions in a Gaussian cloud.

That geometric picture is the deepest reading. A k-dimensional isotropic Gaussian has spherically symmetric density ∝ er2/2, so the squared radius r2 = ∑Zi2 carries all the distributional content; chi-squared is simply the law of that squared radius. The xk/2−1 prefactor is the surface area of a shell of radius √x, and the exponential is the Gaussian weight on that shell. This is why the mode sits at k − 2 rather than the origin even though the Gaussian peaks at the centre: there is far more volume at large radius.

The result seeds a whole family. Ratios of independent chi-squares (each over its degrees of freedom) define the F distribution used in analysis of variance; a standard normal divided by √(Q/k) is Student's t; and the sample variance obeys (n − 1)s22 ~ χ2n−1, which is the engine of every confidence interval for a variance.

The clean subtraction of degrees of freedom when parameters are fitted is the content of Cochran's theorem: if a Gaussian vector is decomposed by orthogonal projections onto subspaces of dimensions d1, d2, …, the squared norms in each subspace are independent chi-squares with those dimensions as their degrees of freedom. Fitting p parameters projects out a p-dimensional subspace, leaving kp in the residual — the abstract reason the naive count is wrong, and the same idea that partitions total variance into orthogonal, independently chi-squared pieces in ANOVA.

Common misconceptions. Chi-squared is not symmetric and its mean is not its mode; a small observed χ2 is not automatically "good," since a value far below the mean can signal overfitting or overestimated errors just as a large value signals a poor model.

Worked examples
1
Sample variance of a normal measurement. n = 10 readings from N(μ, σ2) with σ2 = 4; find the mean and standard deviation of the sample variance s2.
2
(n − 1)s2 ⁄ σ2 ~ χ2n−1,   df = n − 1 = 9
One degree of freedom is lost to the estimated mean, so the standardised sum of squared residuals is chi-squared with 9, not 10. B
3
E[s2] = σ2 ⁄ (n−1) · E[χ29] = σ2⁄9 · 9 = σ2 = 4
Use E[χ29] = 9; the estimator is unbiased. A
4
Var(s2) = (σ2⁄9)2 · Var(χ29) = (σ4⁄81)(2·9) = 2σ4⁄9 = 2·16⁄9 = 3.56
Use Var(χ29) = 2·9 = 18 and propagate the constant. A
E[s2] = 4,   SD(s2) = √3.56 = 1.89

Reading. The variance estimate is centred on the true value 4 but scatters by nearly ±50% with only ten readings — a quantitative warning about trusting variances from small samples.

Units check. s2 has units of σ2 (the measurement squared); its standard deviation likewise, as required.

1
Equipartition from three squared velocities. A gas molecule of mass m at temperature T has velocity components vx, vy, vz ~ N(0, kBT/m). Find the mean and variance of its kinetic energy E = ½m(vx2 + vy2 + vz2).
2
Zi = vi ⁄ √(kBT/m) ~ N(0, 1),   Q = Zx2 + Zy2 + Zz2 ~ χ23
Standardise each independent component; three of them give three degrees of freedom. B
3
E = ½m · (kBT/m) Q = ½kBT Q
Factor the common scale out of the sum; the mass cancels, leaving energy proportional to a χ23 variable. A
4
E[E] = ½kBT · E[Q] = ½kBT · 3 = (3/2)kBT
Insert E[χ23] = 3; this is exactly the equipartition theorem, ½kBT per quadratic degree of freedom. A
5
Var(E) = (½kBT)2 · Var(Q) = ¼(kBT)2 · (2·3) = (3/2)(kBT)2
Use Var(χ23) = 6 and propagate the constant. A
E[E] = (3/2)kBT,   Var(E) = (3/2)(kBT)2

Reading. The chi-squared mean reproduces equipartition exactly, and its variance quantifies the thermal energy fluctuation of a single molecule, of order kBT itself — relative fluctuation √(2/3) ≈ 0.82, large because one molecule is far from the thermodynamic limit.

Units check. Q is dimensionless, kBT is an energy, so E[E] is an energy and Var(E) an energy squared, as required.

Problems
  1. Show that the χ2 distribution with 2 degrees of freedom is an exponential, and compute P(Q > 3).
    SolutionSet k = 2 in the density: f(x) = x0ex/2⁄[21Γ(1)] = ½ex/2, an exponential with mean 2. Then P(Q > 3) = ∫3½ex/2dx = e−3/2 = 0.223.
  2. State the mean, variance, and standard deviation of χ25.
    SolutionMean = k = 5; variance = 2k = 10; standard deviation = √10 = 3.16.
  3. A sample of n = 25 readings comes from N(μ, σ2) with σ2 = 9. Give the degrees of freedom of (n−1)s22 and the standard deviation of s2.
    Solutiondf = n − 1 = 24. Var(s2) = (σ2/24)2·Var(χ224) = (σ4/576)(48) = σ4/12 = 81/12 = 6.75, so SD(s2) = √6.75 = 2.60.
  4. Find the mode of the χ2 density with k degrees of freedom (k ≥ 2), and evaluate the density at the mode for k = 6.
    SolutionMaximise ln f = (k/2 − 1)ln xx/2; setting the derivative (k/2 − 1)/x − ½ = 0 gives mode x = k − 2. For k = 6 the mode is at x = 4; f(4) = 42e−2⁄[23Γ(3)] = 16·0.1353⁄(8·2) = 2.165/16 = 0.135.
  5. Using the central-limit approximation, estimate P(χ250 > 70) and comment on its accuracy.
    SolutionFor k = 50, mean = 50 and SD = √(2·50) = 10. Approximating Q ~ N(50, 100): P(Q > 70) ≈ P(Z > (70−50)/10) = P(Z > 2) = 0.023. The true value is about 0.021, so the plain normal approximation is close but slightly overestimates the right tail because the distribution is still right-skewed at k = 50; a Wilson–Hilferty cube-root transform sharpens the estimate.