Fact-checked by Grok 2 weeks ago

Chi-square

The (also written as χ²) is a continuous in statistics that arises as the sum of the squares of k independent standard random variables, where k is the number of and serves as the . This distribution is right-skewed for small k but approaches a as k increases, with key properties including a mean of k, variance of 2k, and a given by f(x) = [1 / (2^{k/2} Γ(k/2))] x^{(k/2)-1} e^{-x/2} for x ≥ 0. The , developed by in 1900, is a family of tests that rely on the to evaluate whether observed categorical data differ significantly from expected values under a . It is nonparametric, making no assumptions about the underlying distribution of the data beyond the sample being random, and is particularly useful for analyzing frequencies in contingency tables or binned observations. Common variants include the chi-squared goodness-of-fit test, which assesses if sample data conform to a specified theoretical distribution (such as or ) by computing the test statistic χ² = Σ [(O_i - E_i)² / E_i], where O_i are observed counts and E_i are expected counts, with adjusted for the number of bins and estimated parameters. The chi-squared test of independence extends this to two or more categorical variables, testing whether their association is due to chance by comparing observed and expected frequencies in a , using (r-1)(c-1) for r rows and c columns. A related test of homogeneity applies similar logic to compare distributions across multiple populations. These tests are foundational in fields like , social sciences, and for tasks such as validating models, detecting dependencies in survey data, and , though they require adequate sample sizes (typically E_i ≥ 5) to ensure the chi-squared approximation holds. Modern software implementations, including adjustments for small samples like Yates' or alternatives, enhance their applicability.

Chi-squared Distribution

Definition

The chi-squared distribution is a fundamental continuous in statistics, arising naturally in contexts involving sums of squared random variables. It is defined as the distribution of the of the squares of k independent standard random variables, where k represents the . Formally, let Z_1, Z_2, \dots, Z_k be independent and identically distributed as standard normal, Z_i \sim \mathcal{N}(0,1) for i = 1, \dots, k. Then the random variable X = \sum_{i=1}^k Z_i^2 follows a chi-squared distribution with k degrees of freedom, denoted X \sim \chi^2(k). This parameterization features a single parameter k > 0, which can be any positive real number, though it is typically a positive integer in the generative definition above; the support of the distribution is the non-negative real line [0, \infty). The is a special case of the , specifically with k/2 and 2 (or equivalently, rate parameter $1/2). Intuitively, it emerges from s in multivariate normal distributions; for a k-dimensional standard multivariate normal vector \mathbf{Z} \sim \mathcal{N}(\mathbf{0}, \mathbf{I}_k), the \mathbf{Z}^\top \mathbf{Z} follows \chi^2(k).

Probability Functions

The (PDF) of the with k , where k > 0, is expressed as f(x; k) = \frac{1}{2^{k/2} \Gamma(k/2)} x^{k/2 - 1} e^{-x/2}, \quad x \geq 0, and f(x; k) = 0 for x < 0. This form arises because the chi-squared distribution is a special case of the gamma distribution, specifically with shape parameter \alpha = k/2 and scale parameter \theta = 2. To derive the PDF via transformation, consider the sum of squares of k independent standard normal random variables; the joint density, after applying the Jacobian of the transformation to polar coordinates or using the moment-generating function, yields the above expression after integration over the angular components. The cumulative distribution function (CDF) gives the probability that a chi-squared random variable does not exceed x, and is defined as F(x; k) = P\left( \frac{k}{2}, \frac{x}{2} \right) = \frac{\gamma\left( \frac{k}{2}, \frac{x}{2} \right)}{\Gamma\left( \frac{k}{2} \right)}, where P(a, z) denotes the regularized lower incomplete gamma function and \gamma(a, z) is the lower incomplete gamma function. Equivalently, F(x; k) = 1 - \frac{\Gamma\left( \frac{k}{2}, \frac{x}{2} \right)}{\Gamma\left( \frac{k}{2} \right)}, using the upper incomplete gamma function \Gamma(a, z). The incomplete gamma functions are standard special functions tabulated and implemented in numerical libraries. For k > 2, the PDF reaches its mode at x = k - 2, reflecting the location of maximum density; for $1 < k \leq 2, the mode is at x = 0. The distribution exhibits positive skewness, which diminishes as k increases and the shape approaches symmetry; the right tail is heavier than the left, decaying exponentially but more slowly for smaller k. Numerical evaluation of the PDF and CDF poses challenges when k is non-integer, as \Gamma(k/2) requires approximation methods such as the Lanczos series for the gamma function, while the incomplete gamma functions demand careful handling via power series for small arguments or continued fractions for large ones to maintain precision across the domain. These computations are essential in software implementations but can lead to overflow or underflow issues without specialized algorithms.

Moments and Properties

The raw moments of a chi-squared random variable X \sim \chi^2_k with k degrees of freedom are given by \mathbb{E}[X^r] = 2^r \frac{\Gamma\left(\frac{k}{2} + r\right)}{\Gamma\left(\frac{k}{2}\right)} for r > -k/2. The central moments include the mean \mu = k, variance \sigma^2 = 2k, \gamma_1 = \sqrt{8/k}, and excess \gamma_2 = 12/k. The cumulants of the are \kappa_1 = [k](/page/K), \kappa_2 = 2[k](/page/K), and for r \geq 3, \kappa_r = 2^{r-1} (r-1)! \, [k](/page/K). The is \phi(t) = (1 - 2it)^{-[k](/page/K)/2}. Key properties include the additivity of independent chi-squared random variables: if X_i \sim \chi^2_{[k](/page/K)_i} are independent, then \sum X_i \sim \chi^2_{\sum [k](/page/K)_i}, making the distribution reproductive under . For large k, the chi-squared distribution is asymptotically normal by the , approximating \mathcal{N}(k, 2k). Concentration inequalities, such as Bernstein-type bounds, provide tail probabilities; for example, for X \sim \chi^2_k, \Pr(X \geq k + t) \leq \exp\left( -\frac{t^2/2}{k + t/3} \right) for t \geq 0. Cochran's theorem states that for a multivariate with components, a can be partitioned into sums of squares that are chi-squared variables with adding up to the total , applicable to partitioning sums of squares in linear models. The chi-squared distribution with k is a special case of the , specifically \chi^2(k) \sim \Gamma(k/2, 2) where the gamma is parameterized by k/2 and 2./05:_Special_Distributions/5.09:_Chi-Square_and_Related_Distribution) It is also connected to the , as the reciprocal of a chi-squared follows an , which is itself a special case of the inverse-gamma with \nu/2 and $1/2, where \nu = k. For specific values of k, the chi-squared distribution reduces to simpler forms related to other distributions. When k=1, the chi-squared distribution is the distribution of the square of a standard random variable, i.e., if Z \sim N(0,1), then Z^2 \sim \chi^2(1). For k=2, it coincides with an with rate $1/2 (or mean 2), as \chi^2(2) \sim \text{Exp}(1/2)./05:_Special_Distributions/5.09:_Chi-Square_and_Related_Distribution) The generalizes the central chi-squared by allowing the underlying variables to have non-zero means. Specifically, if Z_i \sim N(\mu_i, 1) independently for i=1,\dots,k, then \sum_{i=1}^k Z_i^2 \sim \chi^2(k, \lambda) where \lambda = \sum \mu_i^2 is the . Its involves the modified of the first kind and is given by f(x; k, \lambda) = \frac{1}{2} e^{-(x+\lambda)/2} \left( \frac{x}{\lambda} \right)^{(k-2)/4} I_{(k-2)/2} \left( \sqrt{\lambda x} \right), for x > 0, where I_\nu denotes the modified of order \nu. A further generalization is the , which arises from quadratic forms of normal random variables, expressed as Q = \sum_{i=1}^k a_i Z_i^2 + 2 \sum_{i<j} b_{ij} Z_i Z_j where Z_i \sim N(0,1) independently and a_i, b_{ij} are constants. This encompasses the standard chi-squared when all a_i=1 and cross terms are zero, but allows for weighted sums and linear combinations that capture dependencies. The chi-squared distribution relates to the F-distribution through ratios: if U \sim \chi^2(m) and V \sim \chi^2(n) are independent, then (U/m) / (V/n) \sim [F(m,n)](/page/F-distribution). Similarly, the Student's t-distribution with \nu degrees of freedom is the distribution of T = Z / \sqrt{U/\nu}, where Z \sim N(0,1) independent of U \sim \chi^2(\nu), or equivalently, T^2 \sim [F(1,\nu)](/page/F-distribution). In the multivariate setting, the Wishart distribution serves as a matrix analog of the chi-squared, defined for a p \times p positive semi-definite matrix W = \sum_{i=1}^n X_i X_i^T where X_i \sim N_p(0, \Sigma) independently; thus, W \sim W_p(n, \Sigma). When \Sigma = I_p, the Wishart reduces to a sum of independent chi-squared variables along the diagonal, linking it directly to the univariate case.

Chi-squared Test

Formulation

The chi-squared statistic, often denoted as \chi^2, serves as the primary test statistic in chi-squared tests for categorical data analysis. In its general form for assessing goodness-of-fit or independence, it is computed as \chi^2 = \sum_{i} \frac{(O_i - E_i)^2}{E_i}, where O_i represents the observed frequency in category i, and E_i is the expected frequency under the null hypothesis. This formulation quantifies the discrepancy between observed and expected counts, normalized by the expected values to account for varying category sizes. Karl Pearson introduced this statistic in 1900 as a criterion for evaluating deviations in correlated normal variables, later extending it to categorical data under a multinomial model. The derivation arises from the multinomial likelihood, where the test statistic approximates a quadratic form in the maximum likelihood estimates of category probabilities. Under the null hypothesis of a specified multinomial distribution, the standardized deviations \sqrt{n} (\hat{p} - p) converge by the to a multivariate normal with covariance matrix \Sigma, where the diagonal elements are p_j(1 - p_j) and off-diagonals are -p_j p_l. Projecting onto the subspace orthogonal to the yields the chi-squared form. Under the null hypothesis and with sufficiently large sample sizes, the chi-squared statistic asymptotically follows a chi-squared distribution with k degrees of freedom, where k equals the number of categories minus the number of parameters estimated from the data. For a goodness-of-fit test to a fully specified distribution, the degrees of freedom are m - 1, with m categories; if parameters are estimated (e.g., from the sample mean and variance for a normal fit), subtract the number of estimated parameters. In contingency tables with r rows and c columns, the degrees of freedom are (r-1)(c-1), reflecting the constraints imposed by fixed marginal totals under the independence null. Pearson initially proposed incorrect degrees of freedom for some cases, a error later corrected by . Beyond categorical applications, the chi-squared statistic also tests the variance of a normal distribution. For a sample of size n from N(\mu, \sigma^2), with known \mu or under the null \sigma^2 = \sigma_0^2, the statistic is \chi^2 = \frac{(n-1) s^2}{\sigma_0^2}, which follows a chi-squared distribution with n-1 degrees of freedom, where s^2 is the sample variance. This form originates from the property that the sample variance of normals is a scaled chi-squared random variable.

Assumptions and Limitations

The chi-squared test requires several key assumptions to ensure the validity of its asymptotic approximation to the chi-squared distribution. Observations must be independent, such that the value of one does not influence another, which is typically satisfied through random sampling from distinct units. The data should arise from a multinomial sampling process, suitable for categorical variables where categories are mutually exclusive and exhaustive. Unlike parametric tests for continuous data, the chi-squared test does not require normality in the underlying population asymptotically for tests of independence or goodness-of-fit; however, when applied to test the variance of a normally distributed population, it assumes the data are drawn from a normal distribution to ensure the exact sampling distribution holds. A primary assumption concerns sample size adequacy, specifically that expected frequencies under the null hypothesis are sufficiently large: at least 80% of cells should have expected counts of 5 or greater, with no expected count less than 1, to justify the normal approximation underlying the test statistic. Despite these assumptions, the chi-squared test has notable limitations, particularly with small or sparse data. In small samples, the discrete nature of categorical counts can inflate Type I error rates, as the chi-squared approximation becomes unreliable and p-values may be too small. The test is sensitive to sparse contingency tables, where many cells have low expected frequencies, leading to inconsistent results and reduced accuracy even for moderate sample sizes. Violations of these assumptions can result in loss of statistical power, invalid p-values, and misleading inferences; for instance, low expected frequencies distort the test's ability to detect true associations. Common diagnostics include computing and inspecting the minimum expected frequency across cells to assess approximation quality. When assumptions fail, especially in small samples, simulation-based alternatives such as provide quasi-exact p-values by resampling under the null hypothesis, while exact methods like compute precise distributions without approximations; as of 2025, statistical software such as R and SAS provides options for and recommends these for small or sparse tables (e.g., via warnings and documentation) to improve reliability.

Types of Tests

The chi-squared goodness-of-fit test assesses whether the observed frequencies in a sample align with those expected under a specified probability distribution, such as testing for uniformity or fit to a particular model. The test statistic follows a chi-squared distribution with degrees of freedom equal to the number of categories minus 1 minus the number of parameters estimated from the data. The chi-squared test of independence evaluates whether two categorical variables are independent in a population, using an r \times c contingency table where r and c denote the number of rows and columns, respectively. The degrees of freedom for this test are (r-1)(c-1). The chi-squared test of homogeneity determines whether multiple populations share the same distribution for a categorical variable, often applied to compare proportions across groups. This test employs the same statistic and table structure as the test of independence, with degrees of freedom (r-1)(c-1), but differs in sampling design: independent random samples are drawn from each population rather than a single sample classified by two variables. For normally distributed data, the chi-squared test for variance examines the null hypothesis that the population variance equals a specified value \sigma_0^2. The test statistic is \frac{(n-1)s^2}{\sigma_0^2}, where n is the sample size and s^2 is the sample variance, following a chi-squared distribution with n-1 degrees of freedom. Other variants include Bartlett's test for homogeneity of variances across multiple groups, which tests the null hypothesis of equal variances and approximates a chi-squared distribution with k-1 degrees of freedom, where k is the number of groups. Trend tests, such as the Cochran-Armitage test, detect linear trends in proportions across ordered categories in a contingency table, with the statistic following a chi-squared distribution with 1 degree of freedom. In high-dimensional genomics, chi-squared tests have seen adaptations for sparse contingency tables, such as in gene set enrichment analysis of single-cell RNA sequencing data, where they help control type I error in simulations involving thousands of genes with low expression rates.

Corrections and Alternatives

When the chi-squared test's asymptotic approximation leads to inaccuracies, particularly in contingency tables with small expected frequencies, continuity corrections adjust the test statistic to improve performance. Yates's continuity correction, proposed for 2×2 tables, modifies the Pearson chi-squared statistic by subtracting 0.5 from the absolute difference between observed and expected frequencies before squaring and dividing by the expected value: \chi^2_{\text{adj}} = \sum \frac{(|O_i - E_i| - 0.5)^2}{E_i} This adjustment reduces the tendency to overestimate significance in small samples, though its use is debated for larger tables where it may overly conservative results. For goodness-of-fit tests, Williams' correction refines the likelihood ratio statistic G^2 by dividing it by (1 + (k-1)/6n), where k is the number of categories and n the sample size; this accounts for the discreteness of the data and yields better chi-squared approximations in moderate samples. The Freeman-Tukey statistic, defined as $2 \sum (\sqrt{O_i} - \sqrt{E_i})^2, serves as another adjustment suitable for small samples in both goodness-of-fit and independence tests, offering robustness to zero cells and improved type I error control compared to the uncorrected chi-squared. Non-parametric alternatives circumvent the chi-squared test's reliance on large-sample approximations when assumptions like adequate expected frequencies fail. Fisher's exact test computes the exact probability of observing the data (or more extreme) under the null hypergeometric distribution for 2×2 tables, making it preferable for small or sparse data where chi-squared p-values are unreliable. Barnard's test extends this exact approach to 2×2 tables without conditioning on marginal totals, often providing greater power than Fisher's while maintaining validity. For larger tables, permutation tests generate the null distribution by randomly reshuffling labels or rows to compute an empirical p-value based on the observed statistic, offering flexibility for complex designs without distributional assumptions. In cases involving covariates or modeled relationships, logistic regression can test associations via likelihood ratio tests, providing odds ratios and handling small samples through regularization when the simple independence test is inadequate. Exact tests like Fisher's or Barnard's are recommended for sample sizes under 20 or when more than 20% of cells have expected frequencies below 5, especially in sparse tables, as they avoid approximation errors. For intricate scenarios with structural zeros or high dimensions, Monte Carlo simulations approximate the p-value by generating thousands of random tables under the null and comparing the observed statistic, ensuring controlled error rates. Recent Bayesian analogs, such as the Dirichlet-multinomial model, incorporate priors to stabilize inference in small-sample multinomial settings, yielding posterior predictive checks that parallel chi-squared goodness-of-fit while quantifying uncertainty through credible intervals.

Applications

Hypothesis Testing

The chi-squared test is commonly employed in hypothesis testing to assess whether observed categorical data significantly deviate from expected patterns under a null hypothesis. The general procedure begins by formulating the hypotheses: the null hypothesis H_0 posits no significant difference or association (e.g., data follow a specified distribution or variables are independent), while the alternative H_a suggests otherwise. Next, the test statistic \chi^2 is computed as the sum of squared differences between observed and expected frequencies, divided by the expected frequencies. Degrees of freedom (df) are then determined based on the test type—typically k-1 for goodness-of-fit with k categories, or (r-1)(c-1) for independence in an r \times c contingency table. The p-value is obtained by comparing the \chi^2 statistic to the chi-squared distribution with the given df, using statistical tables or software; if the p-value is less than the significance level \alpha (e.g., 0.05), H_0 is rejected in favor of H_a. A classic application is the goodness-of-fit test to evaluate if a die is fair. Suppose a die is rolled 60 times, yielding observed frequencies of 8, 12, 18, 9, 7, and 6 for faces 1 through 6, respectively. Under H_0, each face has an equal probability of $1/6, so expected frequencies are 10 each. The computed \chi^2 \approx 9.8 with df = 5 yields a p-value of approximately 0.08 (using chi-squared distribution tables or software like R). Since p > 0.05, there is insufficient evidence to reject the , suggesting the die rolls are consistent with fairness. For testing independence between two categorical variables, consider a 2x2 examining (male, female) versus product preference (yes, no) in a survey of 200 respondents. The table might show observed counts such as 50 males preferring yes, 30 no; 40 females yes, 80 no (with expected values calculated row- and column-wise). The test yields df = (2-1)(2-1) = 1. At \alpha = 0.05, the from the chi-squared table is 3.84; the computed \chi^2 \approx 16.5 exceeds this (p < 0.001), so H_0 of is rejected, indicating a significant association between and preference. Power analysis for the chi-squared test evaluates the probability of correctly rejecting H_0 when it is false, influenced by factors such as effect size (magnitude of deviation from independence or fit), sample size, df, and \alpha. Larger effect sizes and sample sizes increase power. Calculations involve the non-central chi-squared distribution, where the non-centrality parameter \lambda (related to effect size and sample size) shifts the distribution; power is the probability that the test statistic exceeds the critical value under this alternative distribution. Software like G*Power or R's pwr.chisq.test facilitates these computations. In machine learning, the chi-squared test is applied to assess feature independence in datasets, aiding preprocessing by identifying non-redundant variables. For instance, in a 2025 study on cardiovascular disease risk prediction using high-dimensional health data, the test was used to select features by evaluating independence from the target outcome, improving model efficiency in a random forest classifier pipeline and reducing dimensionality from over 100 variables while maintaining predictive accuracy.

Parameter Estimation

The chi-squared distribution plays a central role in constructing confidence intervals for the variance of a normal population. For a random sample of size n from a normal distribution with unknown variance \sigma^2, the sample variance S^2 satisfies (n-1)S^2 / \sigma^2 \sim \chi^2_{n-1}, where \chi^2_{n-1} denotes the chi-squared distribution with n-1 degrees of freedom. A (1-\alpha) \times 100\% confidence interval for \sigma^2 is thus given by \frac{(n-1)S^2}{\chi^2_{\alpha/2, n-1}} < \sigma^2 < \frac{(n-1)S^2}{\chi^2_{1-\alpha/2, n-1}}, where \chi^2_{\alpha/2, n-1} and \chi^2_{1-\alpha/2, n-1} are the upper and lower \alpha/2 quantiles of the \chi^2_{n-1} distribution, respectively. In estimating proportions from multinomial data, chi-squared approximations enable simultaneous confidence intervals for multiple categories. Goodman's method constructs such intervals by approximating the Pearson chi-squared statistic for the multinomial distribution, treating it as asymptotically chi-squared with one degree of freedom per proportion under the null of equal probabilities adjusted for the sample. For observed counts O_i in k categories with total N, the (1-\alpha) \times 100\% simultaneous confidence interval for the i-th proportion p_i is \hat{p}_i \pm z_{\alpha/2} \sqrt{\frac{\hat{p}_i (1 - \hat{p}_i)}{N} + \frac{z_{\alpha/2}^2}{3N^2}}, derived from the chi-squared quantile approximation, where \hat{p}_i = O_i / N and z_{\alpha/2} is the standard normal quantile, providing coverage superior to separate binomial intervals for small samples. Extensions like the Wilson score interval for binomial cases (a special multinomial with two categories) similarly rely on chi-squared-based normal approximations for better small-sample performance over the Wald interval. Jeffreys intervals, Bayesian in nature, also approximate posterior quantiles using chi-squared pivots for multinomial proportions in non-informative prior settings. The method of moments provides estimators for parameters that generate chi-squared-like statistics, particularly the degrees of freedom k of a chi-squared distribution itself. For a sample X_1, \dots, X_n from \chi^2_k, the first population moment is E[X] = k, so the method of moments estimator is \hat{k} = \bar{X}, the sample mean. Since the second moment yields \text{Var}(X) = 2k, an alternative estimator is \hat{k} = s^2 / 2, where s^2 is the sample variance; for improved consistency, a combined form \hat{k} = \bar{X}^2 / s^2 equates both moments, though \bar{X} alone is unbiased for k. These estimators underpin moment-based inference for parameters in models where test statistics follow non-central chi-squared distributions, such as in frameworks. Likelihood ratio tests facilitate parameter estimation through asymptotic chi-squared approximations for nested models. Under regularity conditions, for testing a hypothesis restricting q parameters in a model with likelihood L(\theta), the test statistic -2 \log \Lambda = -2 \log (L(\hat{\theta}_0) / L(\hat{\theta})) follows a \chi^2_q distribution asymptotically, where \hat{\theta}_0 and \hat{\theta} are restricted and unrestricted maximum likelihood estimators. This supports confidence regions by inverting the test, estimating parameters via profile likelihoods where the chi-squared critical values define boundaries, widely applied in exponential families and generalized linear models. Quantile-based estimation leverages chi-squared distribution quantiles to infer parameters directly from observed statistics. For instance, matching sample quantiles to theoretical quantiles yields estimators for degrees of freedom or scale in gamma-related models, providing robust alternatives to moment methods when tails are heavy. In robust statistics as of 2025, chi-squared residuals via robust Mahalanobis distances detect outliers in multivariate data. The squared Mahalanobis distance D_i^2 = (x_i - \hat{\mu})^T \hat{\Sigma}^{-1} (x_i - \hat{\mu}), using robust location \hat{\mu} and scatter \hat{\Sigma} (e.g., minimum covariance determinant), approximates \chi^2_p under multivariate normality for p dimensions; observations with D_i^2 > \chi^2_{1-\alpha, p} are flagged as outliers. Recent advances refine this for high dimensions with reweighted estimators, improving breakdown point to 50% while maintaining chi-squared calibration for detection in contaminated datasets.

Other Statistical Uses

In generalized linear models (GLMs), the deviance statistic serves as a measure of model fit, asymptotically following a under the of adequate fit, allowing for likelihood ratio tests to compare nested models. Lack-of-fit tests in , such as those based on partitioning the , also employ chi-squared approximations to assess whether the model adequately captures the data structure, with the test statistic distributed as chi-squared with equal to the difference in parameters between the full and reduced models. In , the —a measure of uniformity in —is often evaluated using chi-squared statistics to detect deviations from expected random distributions, aiding in identifying polyalphabetic ciphers or language patterns by comparing observed coincidences against theoretical expectations under monoalphabetic assumptions. In physics and engineering, the , defined as the chi-squared value divided by the (\chi^2 / \nu \approx 1 for a good fit under the assumption of normally distributed errors), is widely used in least-squares fitting to quantify model goodness-of-fit, where values near 1 indicate consistency between data and model predictions while deviations signal under- or over-fitting. In bioinformatics, chi-squared tests are applied to assess deviations in observed frequencies from expected values under Hardy-Weinberg , enabling detection of or selection pressures by comparing counts across loci. Similarly, for , chi-squared statistics evaluate non-random associations between alleles at different loci, with the test statistic \chi^2 = N D'^2 (where N is sample size and D' is the normalized disequilibrium coefficient) following a to infer evolutionary history or recombination rates. In , chi-squared scores facilitate by measuring dependence between categorical features and targets, ranking features based on their statistics to reduce dimensionality while preserving , as demonstrated in tasks where top-ranked features improve model accuracy. For , chi-squared tests establish thresholds for multivariate outliers by comparing Mahalanobis distances to a , enabling robust identification of deviations in high-dimensional data streams. Recent applications in ethics leverage chi-squared tests to detect in categorical predictions, such as disparities in model outputs across demographic groups, by assessing associations between predicted categories and protected attributes; for instance, surveys from 2025 reveal significant links between AI practitioners' ethics familiarity and mitigation practices, underscoring the test's role in fairness audits.

History

Origins

The conceptual foundations of the emerged in the early 19th century amid efforts to justify the method of for error analysis. , in the second edition of his Théorie analytique des probabilités (1812), offered a probabilistic rationale for by examining the of the sum of squared deviations from the under the assumption of normally distributed errors, providing an early link between error sums and probabilistic behavior. This approach found immediate application in astronomy, where astronomers employed the of residuals to fit observational data to theoretical models, such as planetary orbits, minimizing discrepancies between predicted and measured positions to improve accuracy in . In the 1870s, Friedrich Robert Helmert formalized the of such sums in a series of papers on geodetic measurements. In , Helmert derived the exact for the sum of squared deviations in samples from a population, initially for up to three variables, and extended it in 1876 to the general case, establishing the chi-squared distribution as the of the sample variance under normality assumptions. By the 1880s, the focus shifted toward broader probabilistic interpretations, with exploring the asymptotic properties of sums of squares in relation to probable errors and discordant observations, facilitating the transition from deterministic error theory to modern that would later build upon.

Key Developments

In 1900, introduced the chi-squared (χ²) as a goodness-of-fit measure to assess whether observed deviations from expected frequencies in a dataset could reasonably arise from random sampling, applicable to distributions and other frequency curves. This innovation, detailed in his seminal paper, established the foundation for using χ² in by quantifying the discrepancy between observed and theoretical distributions through the formula χ² = Σ[(observed - expected)² / expected]. During the 1920s, Ronald A. Fisher advanced the application of χ² to contingency tables, clarifying the correct degrees of freedom as (rows - 1)(columns - 1) in his 1922 paper, which resolved earlier ambiguities and improved the test's reliability for testing independence in categorical data. Fisher's work also laid the groundwork for exact tests, emphasizing conditional inference for small samples to avoid reliance on large-sample approximations. In 1934, William G. Cochran's theorem formalized the decomposition of quadratic forms in normal variables into independent χ²-distributed components, enabling precise partitioning of variance in analysis of variance and extending χ²'s utility in experimental design. That same year, Frank Yates proposed a for the χ² test in 2×2 tables with small expected frequencies, modifying the by subtracting 0.5 from the in each cell to better approximate the discrete and reduce Type I error inflation. Post-World War II, the proliferation of precomputed χ² distribution tables in statistical references, such as those compiled in the and 1960s, democratized determination by eliminating tedious manual integrations of the χ² . By the 1970s, software integration accelerated adoption: SAS's initial 1976 release incorporated χ² tests via the PROC FREQ procedure for automated analysis, while the S language, developed in 1976 at , embedded χ² functions for statistical computing, influencing subsequent tools like . In the , computational refinements have focused on exact algorithms for χ² tests, particularly in sparse or high-dimensional tables, using techniques like for conditional exact inference to handle cases where asymptotic approximations fail. These methods, advanced in works from the onward, enable precise hypothesis testing without relying on simulations for tail probabilities. Concurrently, integration into ecosystems, such as Python's library—where scipy.stats.chi2_contingency has supported χ² independence tests since version 0.7 (2009)—has streamlined applications in and large-scale .

References

  1. [1]
    1.3.6.6.6. Chi-Square Distribution - Information Technology Laboratory
    Probability Density Function, The chi-square distribution results when ν independent variables with standard normal distributions are squared and summed.
  2. [2]
    [PDF] chi-square test - analysis of contingency tables - University of Vermont
    The original chi-square test, often known as Pearson's chi-square, dates from papers by Karl Pearson in the earlier 1900s.
  3. [3]
    THE CHI SQUARE TEST: An Introduction - PMC - NIH
    The Chi square test is a statistical test which measures the association between two categorical variables.
  4. [4]
    1.3.5.15. Chi-Square Goodness-of-Fit Test
    The chi-square test (Snedecor and Cochran, 1989) is used to test if a sample of data came from a population with a specific distribution. An attractive feature ...
  5. [5]
  6. [6]
    Chi-square distribution | Mean, variance, proofs, exercises - StatLect
    A random variable has a Chi-square distribution if it can be written as a sum of squares of independent standard normal variables.
  7. [7]
    15.8 - Chi-Square Distributions | STAT 414
    In Stat 415, you'll see its many applications. As it turns out, the chi-square distribution is just a special case of the gamma distribution! Let's take a look.
  8. [8]
    Chi-squared distribution - The Book of Statistical Proofs
    Oct 13, 2020 · Definition: Let X1,…,Xk X 1 , … , X k be independent random variables where each of them is following a standard normal distribution:.
  9. [9]
    Stat 5421 Notes: To Accompany Agresti Ch 1
    Sep 17, 2025 · ... chi-squared distribution with degrees of freedom that is the ... non-integer degrees of freedom (it can be any positive real number) ...
  10. [10]
  11. [11]
    Proof: Chi-squared distribution is a special case of gamma distribution
    Oct 12, 2020 · Theorem: The chi-squared distribution with k degrees of freedom is a special case of the gamma distribution with shape k2 and rate 12 : X∼Gam(k ...
  12. [12]
    Normal distribution - Quadratic forms - StatLect
    The following proposition shows that certain quadratic forms in standard normal random vectors have a Chi-square distribution. Proposition Let X be a Kx1 ...Review of relevant results from... · Trace of a matrix · Quadratic forms in standard...
  13. [13]
    Proof: Relationship between multivariate normal distribution and chi ...
    Dec 20, 2022 · Then, the quadratic form of x x , weighted by Σ Σ , follows a chi-squared distribution with n n degrees of freedom: y=xTΣ−1x∼χ2(n).(2) (2) ...
  14. [14]
    10.2 The Chi Square Distribution – Introduction to Statistics
    For χ 2 , enter the χ 2 -score. For degrees of freedom, enter the value of the degrees of freedom for the χ 2 -distribution. For logic operator, enter true.<|control11|><|separator|>
  15. [15]
    Chi-Squared Distribution -- from Wolfram MathWorld
    A chi^2 distribution a gamma distribution with theta=2 and alpha=r/2, where r is the number of degrees of freedom.
  16. [16]
    9.3 Chi-Square Distribution - Mathematics
    As with all distributions before, one can determine the mean, variance, skewness and kurtosis for a general χ2 χ 2 distribution directly.
  17. [17]
    [PDF] Some Basic Concentration Inequalities - Andrew B. Nobel
    Bound for Chi-squared Distribution. Fact: Let X ∼ χ2 k. Then. 1. X d. = Pk i=1 ... 2, Bernstein's inequality shows for t ≥ 0. P. 1 n n. X i=1. Xi − p ≥ t.
  18. [18]
    InverseChiSquareDistribution - Wolfram Language Documentation
    InverseChiSquareDistribution[ν] is the distribution followed by the reciprocal of a chi-squared random variable, whereas InverseChiSquareDistribution[ν,ξ] is ...Missing: gamma | Show results with:gamma
  19. [19]
    Chi Square Distribution - Online Statistics Book
    Therefore, Chi Square with one degree of freedom, written as χ2(1), is simply the distribution of a single normal deviate squared. The area of a Chi Square ...
  20. [20]
    [PDF] Lecture 13: Noncentral χ
    The chi-square distribution defined earlier is a special case of the noncentral chi-square distribution with δ = 0 and, therefore, is sometimes called a central ...
  21. [21]
    Noncentral Chi-Squared Distribution - Boost
    Where f(x;ν) is the PDF of the central Chi Squared Distribution and Iv(x) is a modified Bessel function, see cyl_bessel_i. For small values of the non- ...
  22. [22]
    [PDF] Generalization of Chi-square Distribution
    Mar 1, 2015 · Abstract: In this paper, we define a generalized chi-square distribution by using a new parameter k > 0. we give some properties of the.
  23. [23]
    4.2 - The F-Distribution | STAT 415
    If U and V are independent chi-square random variables with r 1 and r 2 degrees of freedom, respectively, then: F = U / r 1 V / r 2. follows an F-distribution ...
  24. [24]
    16.5 - The Standard Normal and The Chi-Square | STAT 414
    The relationship between the normal distribution and the chi-square distribution. The following theorem clarifies the relationship.
  25. [25]
    Wishart distribution | Properties, proofs - StatLect
    The Wishart distribution is a multivariate continuous distribution which generalizes the Gamma distribution.How the distribution is derived · Definition · Relation to the multivariate...
  26. [26]
    [PDF] Lecture 2. The Wishart distribution
    The Wishart distribution is a multivariate extension of χ2 distribution. In particular, if. M ∼ W1(n, σ2), then M/σ2 ∼ χ2 n. For a special case Σ = I, Wp(n ...
  27. [27]
    [PDF] Seven proofs of the Pearson Chi-squared independence test ... - arXiv
    Sep 3, 2018 · Abstract. This paper revisits the Pearson Chi-squared independence test. After presenting the underlying theory with modern notations and ...
  28. [28]
    1.3.5.8. Chi-Square Test for the Variance
    The key element of this formula is the ratio s/σ0 which compares the ratio of the sample standard deviation to the target standard deviation. The more this ...
  29. [29]
    The Four Assumptions of a Chi-Square Test - Statology
    Aug 14, 2021 · This test makes four assumptions: Assumption 1: Both variables are categorical. It's assumed that both variables are categorical.
  30. [30]
    Chi-Square Test for Association using SPSS Statistics
    Assumption #1: Your two variables should be measured at an ordinal or nominal level (i.e., categorical data). You can learn more about ordinal and nominal ...
  31. [31]
    The Chi-square test of independence - PMC - NIH
    Jun 15, 2013 · The value of the cell expecteds should be 5 or more in at least 80% of the cells, and no cell should have an expected of less than one (3). This ...Missing: sparse | Show results with:sparse
  32. [32]
    A Warning on the Use of Chi-Squared Statistics with Frequency ...
    When applied to frequency tables with small expected cell counts, Pearson chi-squared test statistics may be asymptotically inconsistent.Missing: limitations | Show results with:limitations
  33. [33]
    [PDF] PERFORMANCE OF THE EXACT AND CHI-SQUARE TESTS ON ...
    It is possible to obtain statistically significant results in sparse tables using Fisher's exact test, whereas the chi-square test is generally unreliable in ...
  34. [34]
    Simulation Chi-square Test | Real Statistics Using Excel
    Describes how to calculate a quasi-exact version of the chi-square test for independence using simulation in Excel. Examples and software are provided.
  35. [35]
    The Choice Between Pearson's χ 2 Test and Fisher's Exact Test for 2 ...
    Mar 29, 2025 · For statistical inference on a 2 × 2 contingency table, there are two commonly used methods: Pearson's χ2 test and Fisher's exact test [1].
  36. [36]
    11.3 - Chi-Square Test of Independence - STAT ONLINE
    The chi-square test of independence uses this fact to compute expected values for the cells in a two-way contingency table under the assumption that the two ...
  37. [37]
    Test of Homogeneity – Concepts in Statistics
    The difference between these two tests is subtle. They differ primarily in study design. In the test of independence, we select individuals at random from a ...
  38. [38]
    1.3.5.7. Bartlett's Test - Information Technology Laboratory
    Purpose: Test for Homogeneity of Variances, Bartlett's test (Snedecor and Cochran, 1983) is used to test if k samples have equal variances.
  39. [39]
    [PDF] Biostatistics 513
    χ2 test of homogeneity. 2. χ2 test of independence. 3. χ2 test for trend in proportions. Factors and Contingency Tables. Page ...
  40. [40]
    [PDF] Statistical and Computational Methods for High-Dimensional ...
    ... gene sets to chi-squared test statistics then calculated 𝜆gc by dividing the resulting chi-squared test statistics by the expected median of a chi- squared ...
  41. [41]
    Assessing Multinomial Distributions with a Bayesian Approach - MDPI
    Jul 6, 2023 · This paper introduces a unified Bayesian approach for testing various hypotheses related to multinomial distributions.
  42. [42]
    Chi-square Test and its Application in Hypothesis Testing - LWW.com
    The logic of hypothesis testing was first invented by Karl Pearson (1857-1936), a renaissance scientist, in Victorian London in 1900. [1] Pearson's Chi ...
  43. [43]
    How to Perform a Chi-Square Test by Hand (Step-by-Step) - Statology
    Sep 24, 2021 · This tutorial explains how to perform a Chi-Square goodness of fit test by hand, including a step-by-step example.<|control11|><|separator|>
  44. [44]
    2.4 - Goodness-of-Fit Test | STAT 504
    A goodness-of-fit test measures how well observed data corresponds to a fitted model, comparing observed to expected values to see if the model fits.
  45. [45]
    SPSS Tutorials: Chi-Square Test of Independence - LibGuides
    Nov 3, 2025 · The Chi-Square Test of Independence tests if two categorical variables are associated, determining if they are independent or related.
  46. [46]
    Practical guide to calculate sample size for chi-square test in ...
    May 26, 2025 · The chi-square test has a long history in statistics, with its foundations laid by Karl Pearson in 1900. Pearson introduced the chi-square ...
  47. [47]
    [PDF] Evaluating Feature Selection Methods and Feature Contributions for ...
    Jul 14, 2025 · pipeline for CVD risk prediction using a machine learning algorithm and integrated robust feature selection techniques. ... a Chi-Squared test.
  48. [48]
    On Simultaneous Confidence Intervals for Multinomial Proportions
    placing A by Bi in the confidence interval for 7ri (i = 1, 2, .* * , k), where Bi is the upper /i X 100-th percentile of the chi-square distribution with one ...
  49. [49]
    [PDF] Statistical Inference Lecture 09 Likelihood and Point Estimation
    Feb 7, 2013 · The method of moments estimators are. ˆk = X. 2. X − 1 n ∑n i=1 ... Yi is also chi-squared with degrees of freedom equal to ∑ k i=1 ri ...
  50. [50]
    [PDF] Generalized Linear Models: The Big Picture
    = 1, can perform a chi-squared test. • If not: • Estimate 𝜎2 using ... • Squares add up to the Deviance and are chi-square distributed. • Residuals ...
  51. [51]
    [PDF] Tests for Lack-of-Fit of Regression Models - University Digital ...
    To compare the Chi-squared approximation with the bootstrap, we gener- ated 500 samples in a simple linear regression model and computed the test and the p ...
  52. [52]
    [PDF] THE INDEX OF COINCIDENCE - National Security Agency
    The chi-square test is a standard statistic for comparing two distributions. It is more flex- ible than the I.C. and its use has been described in many places.
  53. [53]
    [PDF] Dos and don'ts of reduced chi-squared - arXiv
    Dec 16, 2010 · Reduced chi-squared is a very popular method for model assessment, model comparison, convergence diagnostic, and error estimation in astronomy. ...Missing: physics | Show results with:physics
  54. [54]
    Identifying consistent allele frequency differences in studies of ...
    May 2, 2017 · The G- test is similar to the Chi- squared test but with more general application. The. G- test is based on the log- likelihood ratio test ...
  55. [55]
    [PDF] An Extensive Empirical Study of Feature Selection Metrics for Text ...
    Commonly Known Metrics: Chi: Chi-Squared is the common statistical test that measures divergence from the distribution expected if one assumes the feature ...
  56. [56]
    [PDF] Chi² Test to Determine the Cut-Off Value for Anomalies Detection ...
    This work aims to contemplate the detection of possible anomalies in a dynamic, robust, and effective way using. Mahalanobis distance readily with the Chi² ...<|separator|>
  57. [57]
    Karl Pearson and the Chi-Squared Test - jstor
    The enquiry must begin long before 1890, and an appropriate starting point is 1811. In that year, Laplace was concerned to justify the method of least squares ...
  58. [58]
    [PDF] Distributions-Connections.pdf - USC Dornsife
    • χ2, t: around 1875 by Friedrich Robert Helmert (1843–1917, German geodesist), and then re-discovered, in early 1900-s, in English, by William Sealy ...
  59. [59]
    MTH410 - Mathematical Statistics - Confidence Intervals: Small ...
    ... sum of squares ... It turns out that this distribution has PDF given by (Helmert (1875 ... The resulting curve looks like a heavy-tailed normal distribution ...
  60. [60]
    [PDF] Karl Pearson a - McGill University
    goodness of fit provided by the normal curve, that curve would never have obtained its present position in the theory of errors. Even today there are those ...
  61. [61]
    [PDF] On the Interpretation of χ<sup>2</sup> from Contingency Tables ...
    ON THE INTERPRETATION OF X2 FROM CONTINGENCY TABLES,. AND THE CALCULATION OF P. By R. A. FISHER, M.A., Rothamsted Experiment Station. IT is well known ...
  62. [62]
    The distribution of quadratic forms in a normal system, with ...
    The distribution of quadratic forms in a normal system, with applications to the analysis of covariance. By W. G. COCHRAN, B.A.,. St John's College.
  63. [63]
    Contingency Tables Involving Small Numbers and the χ<sup ... - jstor
    CONTINGENCY TABLES INVOLVING SMALL NUMBERS AND THE. X2 TEST. By F. YATES, B.A.. Introduction. THERE has in the past been a good deal of ...Missing: PDF | Show results with:PDF
  64. [64]
    Cochran, W.G. (1934) The Distribution of Quadratic Forms in a ...
    ABSTRACT: The aim of this paper is to present a generalization of the Shapiro-Wilk W-test or Shapiro-Francia W'-test for application to two or more variables.Missing: original | Show results with:original
  65. [65]
    [PDF] Using Exact Tests from Algebraic Statistics in Sparse Multi ... - arXiv
    Dec 26, 2023 · Chain Monte Carlo (MCMC) algorithm for exact inference on multi-way tables by drawing on techniques from algebraic and polyhedral geometry ...
  66. [66]
    chi2_contingency — SciPy v1.16.2 Manual
    This function computes the chi-square statistic and p-value for the hypothesis test of independence of the observed frequencies in the contingency table.Scipy.stats.chi2_contingency · 1.7.1 · 1.15.0 · 1.14.1