Chi-Square Calculator
Testing Whether Observed Counts Fit Expectations
The chi-square statistic answers a question that comes up constantly with categorical data: do the counts I actually observed look like what I expected, or is the difference too large to attribute to chance? This calculator covers the two most common applications — goodness of fit, checking observed counts against a theoretical distribution, and a 2×2 test of independence, checking whether two categorical variables are related.
The Formula
O is each observed count and E is the corresponding expected count. Larger deviations between observed and expected produce a larger χ² value and a smaller p-value. For the 2×2 independence test, expected counts are computed from the row and column totals under the assumption that the two variables are unrelated.
Worked Example: Testing Die Fairness
Rolling a die 60 times should produce 10 of each face if it's fair. Suppose the actual counts were 8, 12, 9, 11, 10, 10:
| χ² | Degrees of freedom | p-value |
|---|---|---|
| 1.00 | 5 | 0.9626 |
A p-value this high (far above the conventional 0.05 threshold) means these counts are entirely consistent with a fair die — there's no statistical evidence of bias.
Chi-Square Critical Values
| df | α = 0.05 | α = 0.01 |
|---|---|---|
| 1 | 3.841 | 6.635 |
| 2 | 5.991 | 9.210 |
| 3 | 7.815 | 11.345 |
| 4 | 9.488 | 13.277 |
| 5 | 11.070 | 15.086 |
| 10 | 18.307 | 23.209 |
Where This Matters
- Market research — testing whether customer preferences differ significantly from an assumed distribution.
- Genetics — comparing observed inheritance ratios against Mendelian expectations.
- Survey analysis — testing whether two categorical variables, like region and product preference, are statistically associated.
- Fairness and randomness testing — verifying dice, cards, or random number generators behave as expected.
How to Use This Calculator
- Choose Goodness of Fit Test or Test of Independence (2x2 Table) from the dropdown.
- For goodness of fit: enter comma-separated observed and expected values.
- For independence: enter the four cell counts of your 2×2 contingency table.
- Select Calculate to get the χ² statistic, degrees of freedom, and p-value.
Related Calculations
For comparing means instead of counts, see the T-Test Calculator. To measure the strength of a relationship between two continuous variables, use the Correlation Calculator.