Chi-Square Test Calculator – Testing Categorical Data with χ²
The chi-square (χ²) test is the standard statistical tool for analyzing categorical data — counts sorted into buckets rather than continuous measurements. Wherever a statistics course, survey, or lab report asks whether a set of frequencies matches an expectation, or whether two categorical variables are related, the chi-square distribution is the underlying math. This calculator covers the four situations that come up most often: goodness-of-fit, test of independence (including test of homogeneity), a variance test, and a standalone critical-value / p-value lookup.
Goodness of Fit
A goodness-of-fit test asks whether the observed counts in a single categorical variable match a hypothesized distribution. The statistic is χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ, summed across every category, with df = k − 1 where kis the number of categories. Typical examples include checking whether dice rolls are uniformly distributed, whether a survey's demographic split matches census figures, or whether offspring ratios in a genetics experiment match the Mendelian prediction. Expected values can be entered directly as counts, or as proportions that the calculator automatically scales to the observed total.
Test of Independence & Homogeneity
The test of independence uses a contingency table — a cross-tabulation of two categorical variables — to check whether they are statistically associated. Expected counts for each cell are computed as Eᵢⱼ = (row total × column total) / grand total, and df = (rows − 1) × (columns − 1). The identical math also answers the "test of homogeneity" question: whether several populations share the same distribution across categories, just framed as comparing groups rather than testing association. For 2×2 tables, the calculator can optionally apply Yates' continuity correction, which shrinks each squared deviation by 0.5 before dividing by the expected count to reduce the bias introduced when approximating a discrete outcome with a continuous curve.
Variance Test
Beyond categorical counts, the chi-square distribution also underlies the classic test for a single population variance. Given a sample variance s², sample size n, and a hypothesized population variance σ₀², the statistic is χ² = (n − 1)s² / σ₀² with df = n − 1. The calculator supports two-tailed (σ² ≠ σ₀²), upper-tailed (σ² > σ₀²), and lower-tailed (σ² < σ₀²) alternatives, each with the matching critical value(s).
Effect Size & Residuals
A significant χ² result tells you an association or deviation exists, but not how strong it is. Cramér's V — V = √(χ² / (n × min(rows − 1, columns − 1))) — rescales the statistic to a 0–1 range that is comparable across table sizes; for 2×2 tables the equivalent φ coefficient is reported too. Standardized residuals ((O − E) / √E) highlight exactly which cells are driving a significant result, which is often more useful than the aggregate statistic alone.
How the Calculation Works
Under the null hypothesis, the χ² statistic follows a chi-square distribution with the computed degrees of freedom. The calculator derives the p-value and critical value from the regularized incomplete gamma function — the same mathematical object behind the textbook chi-square table — using a numerically stable series expansion combined with a continued-fraction approximation, so results stay accurate across a wide range of degrees of freedom without relying on lookup tables.
Common Use Cases
Students verify textbook examples and homework answers; researchers test survey responses across demographic groups; quality-control teams check whether defect categories occur in expected proportions; and product teams compare conversion-category distributions between A/B/n test variants. In every case, the chi-square test converts a table of counts into a single, interpretable statistic — with this calculator handling the incomplete gamma function so you don't have to.