{
  "id": "chi-squared-distribution",
  "title": "Chi-squared Distribution",
  "lang": "en",
  "source_lang": "en",
  "summary": "The chi-squared distribution describes sums of squared independent standard normal variables and underlies many statistical tests and methods for estimating variance.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "Chi-square distribution",
    "χ² distribution",
    "Central chi-squared distribution"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/chi-squared-distribution/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/chi-squared-distribution/",
      "json": "https://aiwiki.page/zh/chi-squared-distribution.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The chi-squared distribution is a continuous probability distribution that, for a positive integer \\(k\\), describes the sum of the squares of \\(k\\) independent standard normal random variables. The parameter \\(k\\) is called the number of degrees of freedom. Written \\(\\chi_k^2\\), 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 \\(k\\), extending it beyond the integer-valued construction."
    },
    {
      "heading": "Definition and density",
      "text": "Let \\(Z_1,\\ldots,Z_k\\) be independent random variables, each having the standard normal distribution, with mean zero and variance one. Then\n\n\\[X=\\sum_{i=1}^{k}Z_i^2\\]\n\nhas a chi-squared distribution with \\(k\\) degrees of freedom:\n\n\\[X\\sim\\chi_k^2.\\]\n\nThe independence assumption is essential: a sum of squared standard normal variables that are correlated need not have this distribution.\n\nFor any real \\(k>0\\), the probability density function is\n\n\\[f(x;k)= \\frac{x^{k/2-1}e^{-x/2}} {2^{k/2}\\Gamma(k/2)}, \\qquad x>0,\\]\n\nand is zero for \\(x<0\\). Here \\(\\Gamma\\) is the gamma function. The value assigned to a density at the single point \\(x=0\\) does not affect probabilities. There is no point mass at zero.\n\nThe cumulative distribution function is\n\n\\[F(x;k)= \\frac{\\gamma(k/2,x/2)}{\\Gamma(k/2)}, \\qquad x\\geq 0,\\]\n\nwhere the lower incomplete gamma function is defined by\n\n\\[\\gamma(a,z)=\\int_0^z t^{a-1}e^{-t}\\,dt.\\]\n\nConsequently, the chi-squared distribution is a special case of the gamma distribution, with shape \\(k/2\\) and scale \\(2\\). Under the alternative shape–rate convention, its rate is \\(1/2\\)."
    },
    {
      "heading": "Shape and numerical characteristics",
      "text": "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.\n\nIts expected value and variance are\n\n\\[\\operatorname{E}[X]=k, \\qquad \\operatorname{Var}(X)=2k.\\]\n\nIts standard deviation is therefore \\(\\sqrt{2k}\\). Its skewness and excess kurtosis are\n\n\\[\\sqrt{\\frac{8}{k}} \\quad\\text{and}\\quad \\frac{12}{k},\\]\n\nrespectively.\n\nFor \\(k>2\\), the density has its maximum at \\(x=k-2\\). At \\(k=2\\), the density decreases from its largest boundary value at zero. For \\(0<k<2\\), it is unbounded as \\(x\\) approaches zero from the right, although its integral remains finite.\n\nThe moment-generating function is\n\n\\[M_X(t)=(1-2t)^{-k/2}, \\qquad t<\\frac12.\\]\n\nMore generally,\n\n\\[\\operatorname{E}[X^r] = 2^r\\frac{\\Gamma(k/2+r)}{\\Gamma(k/2)}, \\qquad r>-\\frac{k}{2}.\\]\n\nTwo useful special cases are:\n\n- \\(\\chi_1^2\\): the distribution of the square of one standard normal variable.\n- \\(\\chi_2^2\\): an exponential distribution with mean \\(2\\)."
    },
    {
      "heading": "Additivity and geometric interpretation",
      "text": "Sums of independent chi-squared variables\n\nIf \\(X_1,\\ldots,X_m\\) are independent and\n\n\\[X_j\\sim\\chi_{k_j}^2,\\]\n\nthen\n\n\\[\\sum_{j=1}^{m}X_j \\sim \\chi_{\\sum_{j=1}^{m}k_j}^2.\\]\n\nThis 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.\n\nSquared distances and projections\n\nFor an integer \\(k\\), a vector of \\(k\\) independent standard normal coordinates has a multivariate normal distribution. Its squared Euclidean distance from the origin has distribution \\(\\chi_k^2\\).\n\nMore generally, let \\(\\mathbf Z\\) be a standard normal vector in \\(n\\) dimensions, and let \\(P\\) be a symmetric idempotent matrix:\n\n\\[P^\\mathsf T=P, \\qquad P^2=P.\\]\n\nSuch a matrix represents an orthogonal projection. If its rank is \\(r>0\\), then the quadratic form\n\n\\[\\mathbf Z^\\mathsf T P\\mathbf Z \\sim\\chi_r^2.\\]\n\nThe 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.\n\nA 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."
    },
    {
      "heading": "Inference about a normal population variance",
      "text": "Suppose \\(X_1,\\ldots,X_n\\) are independent observations from a normal population with mean \\(\\mu\\) and variance \\(\\sigma^2\\). Define the sample mean and sample variance by\n\n\\[\\overline X=\\frac1n\\sum_{i=1}^{n}X_i, \\qquad S^2=\\frac1{n-1}\\sum_{i=1}^{n}(X_i-\\overline X)^2.\\]\n\nThen\n\n\\[\\frac{(n-1)S^2}{\\sigma^2} \\sim\\chi_{n-1}^2.\\]\n\nMoreover, \\(\\overline X\\) and \\(S^2\\) are independent under the normal model.\n\nThere are \\(n-1\\), rather than \\(n\\), degrees of freedom because the residuals satisfy the constraint\n\n\\[\\sum_{i=1}^{n}(X_i-\\overline X)=0.\\]\n\nIf the population mean is known and used instead of the sample mean, then\n\n\\[\\frac{\\sum_{i=1}^{n}(X_i-\\mu)^2}{\\sigma^2} \\sim\\chi_n^2.\\]\n\nThese results provide exact tests of hypotheses about a normal population variance and exact confidence intervals. If \\(q_p\\) denotes the \\(p\\)-quantile of \\(\\chi_{n-1}^2\\), a two-sided confidence interval with confidence level \\(1-\\alpha\\) is\n\n\\[\\left[ \\frac{(n-1)S^2}{q_{1-\\alpha/2}}, \\frac{(n-1)S^2}{q_{\\alpha/2}} \\right].\\]\n\n“Exact” here means that the coverage probability is exactly \\(1-\\alpha\\) under the stated model. For nonnormal populations, the scaled sample variance generally does not have this chi-squared distribution."
    },
    {
      "heading": "Chi-squared tests for categorical data",
      "text": "The distribution is widely used in statistical hypothesis testing through Pearson’s chi-squared tests. A common statistic is\n\n\\[X^2=\\sum_{i=1}^{m}\\frac{(O_i-E_i)^2}{E_i},\\]\n\nwhere \\(O_i\\) is an observed count and \\(E_i>0\\) is the corresponding expected count under the null hypothesis.\n\nThe 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.\n\nGoodness of fit\n\nFor \\(n\\) independent observations classified into \\(m\\) mutually exclusive categories with specified probabilities \\(p_1,\\ldots,p_m\\),\n\n\\[E_i=np_i.\\]\n\nUnder suitable conditions,\n\n\\[X^2\\xrightarrow{d}\\chi_{m-1}^2.\\]\n\nOne degree of freedom is lost because the observed counts sum to the fixed total \\(n\\). If \\(p\\) identifiable model parameters are estimated from the same counts by an appropriate fitting procedure, the usual limiting degrees of freedom become\n\n\\[m-1-p.\\]\n\nThis subtraction requires regularity conditions and is not valid for every estimation procedure or model.\n\nIndependence in contingency tables\n\nFor an \\(r\\times c\\) contingency table, the expected count under row–column independence is estimated by\n\n\\[E_{ij} = \\frac{O_{i+}O_{+j}}{n},\\]\n\nwhere \\(O_{i+}\\) and \\(O_{+j}\\) are the row and column totals. Under standard large-sample conditions, Pearson’s statistic has an approximate chi-squared distribution with\n\n\\[(r-1)(c-1)\\]\n\ndegrees of freedom.\n\nA test’s p-value is usually obtained from the upper tail:\n\n\\[p=\\Pr\\!\\left(\\chi_\\nu^2\\geq x_{\\mathrm{obs}}^2\\right).\\]\n\nApproximation limits\n\nThe 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.\n\nDependent 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."
    },
    {
      "heading": "Regression and likelihood-based inference",
      "text": "Normal linear models\n\nIn a linear regression model\n\n\\[\\mathbf Y=A\\boldsymbol\\beta+\\boldsymbol\\varepsilon, \\qquad \\boldsymbol\\varepsilon\\sim N_n(\\mathbf0,\\sigma^2I),\\]\n\nsuppose the design matrix \\(A\\) has rank \\(p<n\\). Under ordinary least squares, the residual sum of squares satisfies\n\n\\[\\frac{\\operatorname{RSS}}{\\sigma^2} \\sim\\chi_{n-p}^2.\\]\n\nThis 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 \\(n-p\\).\n\nChi-squared decompositions also underlie analysis of variance, where independent sums of squares are compared after accounting for their degrees of freedom.\n\nLikelihood-ratio statistics\n\nFor nested statistical models, consider\n\n\\[W= 2\\left[ \\ell(\\widehat{\\theta}_{\\mathrm{full}}) - \\ell(\\widehat{\\theta}_{\\mathrm{restricted}}) \\right],\\]\n\nwhere \\(\\ell\\) 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, \\(W\\) converges in distribution to a chi-squared variable whose degrees of freedom equal the difference in model dimensions.\n\nThis 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."
    },
    {
      "heading": "Related distributions",
      "text": "Student’s t and F distributions\n\nIf \\(Z\\sim N(0,1)\\) and \\(U\\sim\\chi_\\nu^2\\) are independent, then\n\n\\[T=\\frac{Z}{\\sqrt{U/\\nu}}\\]\n\nhas Student’s t distribution with \\(\\nu\\) degrees of freedom.\n\nIf \\(U\\sim\\chi_{\\nu_1}^2\\) and \\(V\\sim\\chi_{\\nu_2}^2\\) are independent, then\n\n\\[F=\\frac{U/\\nu_1}{V/\\nu_2}\\]\n\nhas an F distribution with \\(\\nu_1\\) and \\(\\nu_2\\) degrees of freedom. These constructions connect normal sample means and variances to familiar regression and analysis-of-variance tests.\n\nNoncentral chi-squared distribution\n\nIf independent normal variables have unit variance but means \\(\\mu_i\\) that are not necessarily zero, then\n\n\\[\\sum_{i=1}^{k}Z_i^2 \\sim\\chi_k^2(\\lambda), \\qquad \\lambda=\\sum_{i=1}^{k}\\mu_i^2.\\]\n\nThis is the noncentral chi-squared distribution, with noncentrality parameter \\(\\lambda\\). The central chi-squared distribution is the case \\(\\lambda=0\\).\n\nIts mean and variance are\n\n\\[k+\\lambda \\quad\\text{and}\\quad 2(k+2\\lambda),\\]\n\nrespectively. Noncentral chi-squared distributions arise under alternatives to null hypotheses and are used to calculate statistical power."
    },
    {
      "heading": "Approximations and computation",
      "text": "For large \\(k\\), the central limit theorem gives\n\n\\[\\frac{X-k}{\\sqrt{2k}} \\xrightarrow{d}N(0,1).\\]\n\nA frequently useful refinement is the Wilson–Hilferty cube-root approximation:\n\n\\[\\frac{ (X/k)^{1/3}-\\left(1-\\frac{2}{9k}\\right) }{ \\sqrt{2/(9k)} } \\approx N(0,1).\\]\n\nIt accounts for some of the distribution’s skewness, but remains an approximation, especially in extreme tails.\n\nStatistical 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."
    },
    {
      "heading": "Historical development",
      "text": "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.\n\nLater 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."
    }
  ],
  "links": [
    "probability-distribution",
    "degrees-of-freedom",
    "statistics",
    "statistical-independence",
    "normal-distribution",
    "probability-density-function",
    "gamma-function",
    "cumulative-distribution-function",
    "expected-value",
    "variance",
    "exponential-distribution",
    "multivariate-normal-distribution",
    "orthogonal-projection",
    "matrix-rank",
    "quadratic-form",
    "sample-mean",
    "confidence-interval",
    "quantile",
    "statistical-hypothesis-testing",
    "null-hypothesis",
    "p-value",
    "linear-regression",
    "ordinary-least-squares",
    "analysis-of-variance",
    "maximum-likelihood-estimation",
    "students-t-distribution",
    "f-distribution",
    "statistical-power",
    "central-limit-theorem",
    "ronald-fisher"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}