This chi-square calculator runs a goodness-of-fit test: enter observed counts and their expected counts (or one expected proportion set) to get χ², degrees of freedom and the exact p-value.
Validity condition: expected counts should generally be ≥ 5 per category (pool small categories or use exact methods otherwise) — χ²’s approximation degrades below that. Independence tests on contingency tables use the same statistic with df = (rows−1)(cols−1) and expected = row×col ÷ total; compute those expected counts and enter them here.
χ² = Σ (Observed − Expected)² ÷ Expected
Each category contributes its squared miss, scaled by what was expected — misses count more where little was expected. Degrees of freedom = categories − 1 (the total is fixed, so the last count is determined). The p-value comes from the chi-square distribution (computed here via the incomplete gamma function; background in our P-Value Calculator). Part of our Statistics Calculators collection.
Worked Example (Verified)
- Observed 10/20/30 vs expected 20/20/20 (defaults): contributions 5 + 0 + 5 → χ² = 10.000, df 2, p = 0.0067 — the distribution is significantly non-uniform at any conventional level (for df 2 the p-value has the closed form e^(−χ²/2) = e^−5, which this engine reproduces)
- The fair-die audit: rolls of 600 with faces 92/105/98/103/97/105 vs expected 100 each → χ² = 1.24, df 5, p ≈ 0.94 — no evidence against fairness (a suspiciously perfect χ² near 0 would be its own red flag — Fisher famously side-eyed Mendel's peas on exactly this logic)
- χ² = 3.84 at df 1 gives p = 0.0500 — the 2×2 table threshold every A/B tester meets
- Which category drives a significant result? Standardized residuals (O−E)/√E beyond ±2 point at the culprits — significance says "somewhere," residuals say "there"
Rules of Engagement
- Counts, not percentages or means — χ² needs raw frequencies and the sample size baked into them.
- Expected ≥ 5 per cell is the standard adequacy rule; below that, pool categories or switch to exact tests (Fisher for 2×2).
- Observations must be independent — one respondent contributing to multiple categories breaks the model.
- A non-significant χ² doesn't prove the expected model; it acquits for lack of evidence at this sample size (power grows with N — huge samples convict trivial deviations, so pair χ² with effect sizes like Cramér's V).
Related Tools
- P-Value Calculator — χ² among its distributions
- T-Test Calculator — the continuous-data counterpart
- Statistics Calculators — the full collection
Frequently Asked Questions
How do you calculate chi-square?
For each category: (observed − expected)² ÷ expected, then sum. Observed 10/20/30 against expected 20/20/20 gives 5 + 0 + 5 = 10, with df = categories − 1 = 2 and p = 0.0067. This calculator does the sum and the distribution lookup.
What does the chi-square p-value mean?
The probability of deviations at least this large if the expected model were true. p = 0.0067 means well-fitting data would look this lopsided less than 1% of the time by chance — evidence against the expected distribution, not proof of any specific alternative.
Can I use this for a test of independence (contingency table)?
Yes, with preparation: compute each cell's expected count as (row total × column total) ÷ grand total, enter observed and expected in matching order, and read χ² — but note df becomes (rows−1)(columns−1), not cells−1, so interpret the printed df accordingly (the χ² and p shown use cells−1; for independence, cross-check p with the P-Value Calculator using the table df).
Why must expected counts be at least 5?
The χ² sampling distribution is an approximation that relies on each cell's counts being large enough to behave near-normally. Sparse expected counts make the approximation anti-conservative (p-values too small). Pooling categories or exact tests are the standard remedies.
What's a good effect size for chi-square?
Cramér's V (= √(χ²/(N·(k−1)))) scales association 0–1 for contingency tables; for goodness-of-fit, report the per-category residuals and the observed-vs-expected proportions themselves. χ² grows with N, so significance alone at huge N can crown a trivial deviation.
Is this chi-square calculator free?
Yes — free, instant, no sign-up.