Chi-Square Inference
One-line statement: Chi-square inference uses the chi-square () distribution to test hypotheses about categorical data and variances by comparing observed counts to expected counts. Key result in words: When data are grouped into categories, the sum of standardized squared deviations between observed and expected frequencies follows (approximately) a chi-square distribution, enabling goodness-of-fit, independence, and homogeneity tests. Where it applies: Categorical/count data, contingency tables, variance estimation for normal populations. Who/when: Karl Pearson introduced the chi-square goodness-of-fit test in 1900; R.A. Fisher corrected the degrees-of-freedom theory in the 1920s.Chi-square inference is a family of statistical procedures built on the chi-square distribution, a continuous probability distribution arising as the sum of squared independent standard normal variables. Its central use is testing whether observed categorical frequencies are consistent with frequencies expected under a null hypothesis, measured by the Pearson chi-square statistic. It also underlies inference about the variance of a normally distributed population. The method matters because vast amounts of real data are categorical—survey responses, biological classifications, defect counts—where means and standard deviations are not the natural objects of study. A surprising fact: although the statistic is built from discrete counts, its sampling distribution is the continuous chi-square curve, valid only as a large-sample approximation, and the "correct" number of degrees of freedom famously eluded Pearson himself for over two decades.
The Core Insight
A single standardized normal deviation squared, , has a chi-square distribution with 1 degree of freedom. If we standardize each category's deviation and square-and-sum across categories, the result behaves—approximately—like a sum of such squared normals. Large discrepancies between what we observe and what we expect produce large values; rare large values are evidence against the null hypothesis. The whole apparatus reduces complicated categorical comparisons to one number and one reference curve.
Formal Statement
The Chi-Square Distribution
A random variable has a chi-square distribution with degrees of freedom, written , if it is the sum of squares of independent standard normal random variables:
Its probability density function on is
Here is the gamma function, is a positive integer (the degrees of freedom), is the variable, and is Euler's number. The mean is and the variance is .
Pearson Chi-Square Statistic
For data sorted into mutually exclusive categories with observed counts and expected counts (under the null hypothesis), the Pearson statistic is
where is the observed frequency in category , is the expected frequency, is the total sample size, and is the hypothesized probability of category .
Pearson's Limit Theorem
Under the null hypothesis fixed and known, as the sample size , the Pearson statistic in [3] converges in distribution to a chi-square random variable:
If the null model contains parameters estimated from the data, the degrees of freedom drop to .
Why It Holds / Derivation
Sketch of Pearson's Theorem
Step 1 — Multinomial setup. The vector of counts follows a multinomial distribution with parameters and , where . Step 2 — Multivariate CLT. Define the standardized deviationsChi-square densities for several degrees of freedom; the right tail beyond the critical value is the rejection region
Karl Pearson | 1857–1936
Karl Pearson, founder of the world's first university statistics department at University College London, introduced the chi-square goodness-of-fit test in his 1900 paper "On the criterion that a given system of deviations...". A polymath trained in mathematics and law, Pearson sought objective criteria for judging how well theoretical curves fit real frequency data—motivated by biological and evolutionary problems from his collaboration with Francis Galton and Walter Weldon. His original derivation, however, used degrees of freedom even when parameters were estimated; this error was decisively corrected by Ronald Fisher.
Building Intuition
Imagine rolling a die 600 times. Under fairness you expect 100 of each face. If you get , the deviations are small relative to , so each standardized term is around 1 or less, and their sum is modest. But produces deviations of 50, 40, etc., whose squares dwarf , inflating . The statistic essentially asks: "In units of natural sampling noise, how far off are we, totalled across all categories?" The chi-square distribution tells us how large that total tends to get by chance alone, so an observed value in the far right tail signals a genuine departure from the model.
Worked Examples
Goodness-of-Fit: Testing a Fair Die
Given: A die is rolled times. Observed counts: . Test : the die is fair () at significance . Step 1 — Expected counts. for each face. Step 2 — Compute terms.Test of Independence: Treatment vs. Outcome
Given: A contingency table of patients:| | Recovered | Not recovered | Row total | |---|---|---|---| | Drug | 50 | 30 | 80 | | Placebo | 35 | 45 | 80 | | Col total | 85 | 75 | 160 |
Test independence of treatment and outcome at .
Step 1 — Expected counts : , , , . Step 2 — Statistic.Common Misconceptions
The chi-square test requires sufficiently large expected counts. A common rule of thumb is that every should be at least 5 (some allow a few as low as 1 if most exceed 5). When expected counts are too small, the continuous chi-square approximation to the discrete multinomial is poor and p-values are unreliable. Remedies include combining categories or using Fisher's exact test. Also note: the statistic uses counts, never proportions or percentages—plugging in percentages is a frequent and fatal error. The chi-square test is not a test of the strength of association. Consider two tables with identical proportions but different sample sizes. With a moderate association may give (not significant), while the same proportions with give (wildly significant). The statistic scales with , so a "significant" result with huge samples can reflect a trivially small effect. Significance importance—report an effect-size measure such as Cramér's alongside the test.Connections
Chi-square inference sits in a web of related ideas. It is a special case of the Likelihood Ratio Test, whose statistic is asymptotically equivalent to Pearson's . The distribution itself is the Gamma Distribution with shape and scale 2, and squaring a single Standard Normal Distribution variable gives . The ratio of two independent chi-squares (scaled) defines the F-Distribution used in Analysis of Variance, while a normal divided by a scaled chi-square root gives the Student t-Distribution. Inference about a normal variance uses , directly linking it to Confidence Intervals.
Real-World Applications
- Genetics (Mendelian ratios): Testing whether observed offspring phenotype counts match expected 9:3:3:1 dihybrid ratios.
- Quality control: Comparing observed defect-type counts across production lines to detect a shifted process.
- Market research: Testing independence between customer demographic and product preference in survey contingency tables.
- Epidemiology: Assessing association between exposure and disease status in case-control studies.
- Political science: Testing homogeneity of candidate support across geographic regions.
- Ecology: Goodness-of-fit of observed species-abundance counts to a hypothesized distribution.
- Cryptanalysis / randomness testing: The chi-square test on byte-frequency counts checks whether a data stream behaves like uniform random output.
Historical Development
- 1875: Friedrich Helmert derives the distribution of the sample variance for normal data—an early implicit chi-square result.
- 1900: Karl Pearson publishes the goodness-of-fit chi-square test, naming the statistic and tabulating its distribution.
- 1904: Pearson extends the method to contingency tables and association.
- 1908–1915: Refinements by Pearson and others on applying the test to estimated parameters (with the degrees-of-freedom error persisting).
- 1922–1924: R.A. Fisher corrects the degrees of freedom, showing that estimating parameters reduces by , sparking a public dispute with Pearson.
- 1924: Fisher publishes tables and clarifies the relationship among , , and distributions.
- 1934: Fisher introduces the exact test for small tables, addressing the small-count limitation.
- 1954: William Cochran articulates practical rules for minimum expected frequencies and validity conditions.
Subtleties & Limits
The chi-square approximation degrades for sparse tables, and there is no universally agreed threshold for "large enough" expected counts—Cochran's rules are heuristics, not theorems. For multi-way contingency tables, log-linear models and the question of which interaction terms to include push beyond classical chi-square testing into model-selection territory where the asymptotic degrees of freedom may not be integers in practice. Continuity corrections (Yates's correction for tables) remain debated: they can over-correct and reduce power. Modern alternatives—exact permutation tests, Monte Carlo p-values, and Bayesian model comparison—address these limits but raise their own questions about computational feasibility and prior sensitivity in high dimensions.