Chi-Square Calculator
Goodness-of-fit test from observed and expected counts.
df = 4 · p = 0.5747
The chi-square goodness-of-fit statistic is χ² = Σ (O − E)² ÷ E. A die rolled 60 times (10 expected per face) with observed 8, 12, 9, 11, 14, 6 gives χ² = 4.2 on 5 df — below the 11.07 critical value, so the die looks fair (p ≈ 0.52).
Does the data fit the expectation?
The chi-square goodness-of-fit test compares the counts you observed against the counts a hypothesis predicts. For each category it takes the gap between observed and expected, squares it, and scales by the expected count — so the same absolute gap matters more where few cases were expected. A large total χ² means the observed and expected distributions diverge more than chance alone would explain.
summed over every category; df = number of categories − 1
Worked example
A die rolled 60 times, expected 10 per face. Observed: 8, 12, 9, 11, 14, 6.
- 1 Find each category’s contribution. (O − E)² ÷ E: 0.4, 0.4, 0.1, 0.1, 1.6, 1.6 for the six faces.
- 2 Sum them for χ². 0.4 + 0.4 + 0.1 + 0.1 + 1.6 + 1.6 = 4.2.
- 3 Compare to the critical value. df = 6 − 1 = 5; the 0.05 critical χ² is 11.07. Since 4.2 < 11.07, the die looks fair (p ≈ 0.52).
Critical χ² values (α = 0.05)
Reject the null when χ² exceeds the value for your degrees of freedom.
| df | Critical χ² | Categories (df + 1) |
|---|---|---|
| 1 | 3.841 | 2 |
| 2 | 5.991 | 3 |
| 3 | 7.815 | 4 |
| 4 | 9.488 | 5 |
| 5 | 11.070 | 6 |
Setting it up and reading the result
Choose expected counts from the null. The expected counts come from whatever hypothesis you’re testing — equal proportions for a fair die, or known population rates for a “does our sample match?” question. They must sum to the same total as the observed counts.
Mind the minimum count rule. The χ² approximation assumes every expected count is at least 5. With sparse categories, combine them or use an exact test instead.
Use counts, not percentages. The test works on raw frequencies. Feeding it proportions or rates breaks the math — convert back to counts first.
Goodness-of-fit vs independence. This tool tests one categorical variable against a predicted distribution. For a contingency table testing whether two variables are related, first compute each expected cell as (row total × column total) ÷ grand total.