The chi-squared distribution is a continuous probability distribution that, for a positive integer , describes the sum of the squares of independent standard normal random variables. The parameter is called the number of degrees of freedom. Written , the distribution is fundamental to statistics, particularly tests involving categorical data, inference about population variances, and large-sample approximations to the distributions of test statistics. Its density also defines a distribution for every positive real value of , extending it beyond the integer-valued construction.
Definition and density
Let be independent random variables, each having the standard normal distribution, with mean zero and variance one. Then
has a chi-squared distribution with degrees of freedom:
The independence assumption is essential: a sum of squared standard normal variables that are correlated need not have this distribution.
For any real , the probability density function is
and is zero for . Here is the gamma function. The value assigned to a density at the single point does not affect probabilities. There is no point mass at zero.
The cumulative distribution function is
where the lower incomplete gamma function is defined by
Consequently, the chi-squared distribution is a special case of the gamma distribution, with shape and scale . Under the alternative shape–rate convention, its rate is .
Shape and numerical characteristics
A chi-squared variable cannot be negative. For small degrees of freedom, its distribution is strongly right-skewed; as the degrees of freedom increase, it becomes more nearly symmetric.
Its expected value and variance are
Its standard deviation is therefore . Its skewness and excess kurtosis are
respectively.
For , the density has its maximum at . At , the density decreases from its largest boundary value at zero. For , it is unbounded as approaches zero from the right, although its integral remains finite.
The moment-generating function is
More generally,
Two useful special cases are:
- : the distribution of the square of one standard normal variable.
- : an exponential distribution with mean .
Additivity and geometric interpretation
Sums of independent chi-squared variables
If are independent and
then
This holds for arbitrary positive real degrees of freedom, not only integers. It follows from the addition rule for independent gamma variables with a common scale.
Squared distances and projections
For an integer , a vector of independent standard normal coordinates has a multivariate normal distribution. Its squared Euclidean distance from the origin has distribution .
More generally, let be a standard normal vector in dimensions, and let be a symmetric idempotent matrix:
Such a matrix represents an orthogonal projection. If its rank is , then the quadratic form
The degrees of freedom count the number of independent normal directions retained by the projection. This explains why constraints and fitted parameters often reduce degrees of freedom in statistical applications.
A general quadratic form in normal variables need not be chi-squared. Unequal weights along independent normal directions ordinarily produce a weighted sum of chi-squared variables instead.
Inference about a normal population variance
Suppose are independent observations from a normal population with mean and variance . Define the sample mean and sample variance by
Then
Moreover, and are independent under the normal model.
There are , rather than , degrees of freedom because the residuals satisfy the constraint
If the population mean is known and used instead of the sample mean, then
These results provide exact tests of hypotheses about a normal population variance and exact confidence intervals. If denotes the -quantile of , a two-sided confidence interval with confidence level is
“Exact” here means that the coverage probability is exactly under the stated model. For nonnormal populations, the scaled sample variance generally does not have this chi-squared distribution.
Chi-squared tests for categorical data
The distribution is widely used in statistical hypothesis testing through Pearson’s chi-squared tests. A common statistic is
where is an observed count and is the corresponding expected count under the null hypothesis.
The statistic measures discrepancies relative to the scale of expected count variation. For categorical data, its chi-squared distribution is usually a large-sample approximation, not an exact finite-sample identity.
Goodness of fit
For independent observations classified into mutually exclusive categories with specified probabilities ,
Under suitable conditions,
One degree of freedom is lost because the observed counts sum to the fixed total . If identifiable model parameters are estimated from the same counts by an appropriate fitting procedure, the usual limiting degrees of freedom become
This subtraction requires regularity conditions and is not valid for every estimation procedure or model.
Independence in contingency tables
For an contingency table, the expected count under row–column independence is estimated by
where and are the row and column totals. Under standard large-sample conditions, Pearson’s statistic has an approximate chi-squared distribution with
degrees of freedom.
A test’s p-value is usually obtained from the upper tail:
Approximation limits
The approximation can be poor when expected counts are small or spread thinly across many cells. Rules such as requiring expected counts of at least five are practical heuristics, not universal mathematical conditions. Accuracy also depends on the number of categories and the pattern of probabilities.
Dependent observations, survey weights, clustering, and structural zeros can change the reference distribution or degrees of freedom. Exact conditional calculations or simulation-based methods can provide alternatives for appropriate sampling models.
Regression and likelihood-based inference
Normal linear models
In a linear regression model
suppose the design matrix has rank . Under ordinary least squares, the residual sum of squares satisfies
This is an exact result under the stated normal-error model. It follows because the residual vector is the projection of the error vector onto a subspace of dimension .
Chi-squared decompositions also underlie analysis of variance, where independent sums of squares are compared after accounting for their degrees of freedom.
Likelihood-ratio statistics
For nested statistical models, consider
where is the log-likelihood and the fitted values are obtained by maximum likelihood estimation. Wilks’s theorem states that, under suitable regularity conditions and the null hypothesis, converges in distribution to a chi-squared variable whose degrees of freedom equal the difference in model dimensions.
This is an asymptotic result. Parameters on boundaries, nonidentifiable parameters, and some mixture models violate the usual assumptions; their limiting distributions need not be ordinary chi-squared distributions.
Related distributions
Student’s t and F distributions
If and are independent, then
has Student’s t distribution with degrees of freedom.
If and are independent, then
has an F distribution with and degrees of freedom. These constructions connect normal sample means and variances to familiar regression and analysis-of-variance tests.
Noncentral chi-squared distribution
If independent normal variables have unit variance but means that are not necessarily zero, then
This is the noncentral chi-squared distribution, with noncentrality parameter . The central chi-squared distribution is the case .
Its mean and variance are
respectively. Noncentral chi-squared distributions arise under alternatives to null hypotheses and are used to calculate statistical power.
Approximations and computation
For large , the central limit theorem gives
A frequently useful refinement is the Wilson–Hilferty cube-root approximation:
It accounts for some of the distribution’s skewness, but remains an approximation, especially in extreme tails.
Statistical software typically evaluates probabilities through incomplete gamma functions and obtains quantiles by numerical inversion. For very small upper-tail probabilities, directly evaluating the upper-tail function avoids the loss of precision that can occur when subtracting a cumulative probability close to one from one.
Historical development
The chi-squared distribution arose from nineteenth-century investigations of normal errors and sums of squared deviations. Its statistical prominence increased with Karl Pearson’s 1900 work on goodness-of-fit testing.
Later work, notably by Ronald Fisher, clarified the role of degrees of freedom and parameter estimation in interpreting chi-squared statistics. These developments connected the distribution to categorical-data analysis, normal-theory inference, and the broader theory of statistical tests.