Chi-squared distribution (source code)

= Chi-squared distribution
{title2=$\chi_k^2$}
{wiki}

= Chi-squared
{synonym}

A <Chi-squared distribution> with $\nu>0$ <statistical degrees of freedom> is a <Gamma distribution> with shape $\nu/2$ and rate $1/2$. Its <Probability density function> is
$$
f(x)=\frac{x^{\nu/2-1}e^{-x/2}}{2^{\nu/2}\Gamma(\nu/2)},\qquad x>0.
$$
For a <positive integer> $k$, a $\chi_k^2$ variable is the sum of squares of $k$ <independent> <standard normal distribution>[standard normal] <random variables>. The gamma definition extends the law to noninteger positive <statistical degrees of freedom>[degrees of freedom]; it does not require a fractional number of Gaussian coordinates.

Its <mean> is $\nu$, its <variance> is $2\nu$, and its <Moment-generating function> is $(1-2t)^{-\nu/2}$ for $t<1/2$. These follow directly from the <Gamma density> or by multiplying the squared-normal transforms in the <integer> case.

The law appears when Gaussian deviations are aggregated as a squared length. For <independent and identically distributed>[iid] observations $X_1,\ldots,X_n\sim N(\mu,\sigma^2)$ with $n\geq2$ and $\sigma>0$, the <Sample variance> $S^2=(n-1)^{-1}\sum_i(X_i-\overline X)^2$ satisfies $(n-1)S^2/\sigma^2\sim\chi_{n-1}^2$. Centering removes the one-dimensional sample-mean direction, leaving $n-1$ <independent> Gaussian coordinates after an <orthogonal matrix>[orthogonal change of basis]. This exact normal-sampling law underlies <confidence interval>[confidence intervals] for a <variance>; it is not a universal variance-sampling formula for arbitrary data.