Functions & Transformations of Random Variables

the distribution of a sum of squares (chi-squared)

Squaring matters because so much of statistics measures distance, and distance is built from squares. The squared error of an estimate, the squared deviation from a mean, the squared length of a vector — all are sums of squares. When the pieces being squared are independent standard normal variables, the resulting sum of squares has a single famous distribution: the chi-squared.

Build it up. Start with one standard normal Z; the distribution of Z^2 is found by the cdf method (squaring folds the line, so P(Z^2 at most y) = P(-sqrt(y) at most Z at most sqrt(y))), and the answer is the chi-squared distribution with 1 degree of freedom. Now add k of these independently: if Z_1, ..., Z_k are independent standard normals, then Z_1^2 + Z_2^2 + ... + Z_k^2 has the chi-squared distribution with k degrees of freedom. The degrees of freedom just count how many independent squared normals went in. Because it is a sum of independent pieces, the chi-squared distributions add: chi-squared on m plus an independent chi-squared on n gives chi-squared on m + n.

This is why chi-squared appears everywhere in inference. The sample variance, being an average of squared deviations from the mean, is (after scaling) chi-squared; goodness-of-fit tests compare observed and expected counts through a sum of squared standardised gaps; the t and F distributions are built from chi-squared parts. Honest fine print: this exact result requires the squared terms to be independent and standard normal — for other distributions the sum of squares is not chi-squared.

Drop three darts whose x, y, z miss-distances are independent standard normals. The squared distance from the bullseye is Z_1^2 + Z_2^2 + Z_3^2, which is chi-squared with 3 degrees of freedom. Its mean equals the degrees of freedom, 3 — a handy check, since E[Z^2] = Var(Z) = 1 for each standard normal.

Adding k independent squared standard normals gives chi-squared with k degrees of freedom.

The terms must be independent and standard normal for the sum of squares to be chi-squared. The same idea is the source of the t and F distributions, but the squares-of-other-distributions are not chi-squared.

Also called
chi-squared from normalssum of squared normals平方和分布卡方分配的由來