The chi-square formula
χ² = Σ (O − E)² ÷ E
goodness of fit: df = k − 1
independence: df = (rows − 1) × (columns − 1), E = row total × column total ÷ grand total
Each cell compares an observed count O with the count E you would expect if the null hypothesis were true. Squaring makes every gap positive, and dividing by E scales it, so a gap of 10 matters more when you expected 20 than when you expected 2,000. The p-value is the chance of a χ² at least this large if the null hypothesis is true. If it is below your significance level, you reject the null hypothesis.
Which test to use
Goodness of fit checks one categorical variable against a claimed distribution: is a die fair, do customers pick the four plans in the proportions the business plan assumed? Test of independence checks two variables measured on the same people: is buying related to which ad someone saw, is smoking related to region? For a 2 × 2 table the calculator also reports Yates' continuity correction, which some textbooks require.
Assumptions
The test needs raw counts of independent observations, each falling into exactly one cell. Expected counts should be at least 5 in most cells (Cochran's rule: no cell below 1 and no more than 20% below 5). With smaller samples use Fisher's exact test instead. A significant result shows an association, not its cause, and with very large samples even trivial differences become significant, which is why the effect size (Cramér's V) is shown as well.
Critical values
| df | α = 0.10 | α = 0.05 | α = 0.01 | α = 0.001 |
|---|---|---|---|---|
| 1 | 2.706 | 3.841 | 6.635 | 10.828 |
| 2 | 4.605 | 5.991 | 9.210 | 13.816 |
| 3 | 6.251 | 7.815 | 11.345 | 16.266 |
| 4 | 7.779 | 9.488 | 13.277 | 18.467 |
| 5 | 9.236 | 11.070 | 15.086 | 20.515 |
| 6 | 10.645 | 12.592 | 16.812 | 22.458 |
| 7 | 12.017 | 14.067 | 18.475 | 24.322 |
| 8 | 13.362 | 15.507 | 20.090 | 26.124 |
| 9 | 14.684 | 16.919 | 21.666 | 27.877 |
| 10 | 15.987 | 18.307 | 23.209 | 29.588 |
| 12 | 18.549 | 21.026 | 26.217 | 32.909 |
| 15 | 22.307 | 24.996 | 30.578 | 37.697 |
| 20 | 28.412 | 31.410 | 37.566 | 45.315 |
| 25 | 34.382 | 37.652 | 44.314 | 52.620 |
| 30 | 40.256 | 43.773 | 50.892 | 59.703 |