Chi-squared

X∼χ2(k)X \sim \chi^2(k)

The sum of k squared independent standard Normal variables. It is the workhorse behind variance estimates and goodness-of-fit tests.

The story

Take kk independent draws from a standard Normal, square each one and add them up. The result is Chi-squared with kk degrees of freedom. Squaring makes everything positive, and because each squared term has mean 1 and variance 2, the total has mean kk and variance 2k2k.

This is why it appears throughout statistical testing: whenever you add up squared standardised discrepancies, such as (observed−expected)2/expected(\text{observed} - \text{expected})^2/\text{expected} in a contingency table, or the squared deviations in a sample variance, a Chi-squared is lurking. For Normal data, (n−1)S2/σ2(n - 1)S^2/\sigma^2 follows Chi-squared with n−1n - 1 degrees of freedom.

Formulas

Support

x>0x > 0

PDF

f(x)=xk/2−1e−x/22k/2 Γ(k/2)f(x) = \frac{x^{k/2 - 1} e^{-x/2}}{2^{k/2}\, \Gamma(k/2)}

CDF

F(x)=γ(k/2, x/2)Γ(k/2)F(x) = \frac{\gamma(k/2,\, x/2)}{\Gamma(k/2)}

Expectation

E[X]=k\mathbb{E}[X] = k

Variance

Var⁡(X)=2k\operatorname{Var}(X) = 2k

Mode

max⁡(k−2,0)\max(k - 2, 0)

Parameters

ParameterWhat it controls
kkThe degrees of freedom: how many squared standard Normals are being added. It is the mean, and the variance is 2k2k.

Where it shows up

  • The Pearson goodness-of-fit test comparing observed and expected counts.
  • Testing for independence in a contingency table.
  • Confidence intervals for a population variance.
  • The squared distance from the origin of a random point in kk-dimensional space with independent standard Normal coordinates.

Try this

  1. Set k=1k = 1 and shade from 0 to 3.84. The probability is 0.95, which matches the Normal: P(Z2≤3.84)=P(∣Z∣≤1.96)P(Z^2 \le 3.84) = P(\lvert Z \rvert \le 1.96).
  2. Step kk from 1 to 2 to 3. The density at zero goes from infinite, to exactly 1/21/2 (the Exponential with rate 1/21/2), to zero with a hump at k−2=1k - 2 = 1. For k≥2k \ge 2 the mode is always k−2k - 2.
  3. Set k=20k = 20, press Draw 1000 and compare the sample variance with 2k=402k = 40. The shape is already fairly close to a Normal with mean 20 and σ≈6.32\sigma \approx 6.32, though still slightly right-skewed.

Related distributions

  • It is the sum of kk squared standard Normals; in particular Z2Z^2 is Chi-squared with k=1k = 1.
  • Chi-squared with kk degrees of freedom is Gamma(k/2,2)\text{Gamma}(k/2, 2).
  • With k=2k = 2 it is the Exponential with rate 1/21/2.
  • If ZZ is standard Normal and VV is an independent Chi-squared(ν)\text{Chi-squared}(\nu), then Z/V/νZ/\sqrt{V/\nu} is Student t with ν\nu degrees of freedom.