Chi-Square Calculator
Run a chi-square goodness-of-fit test or a test of independence — with expected frequencies, exact p-values from the χ² distribution, critical values and a plain-language significance verdict.
| Category | Observed | Expected (count) | |
|---|---|---|---|
| #1 | |||
| #2 | |||
| #3 | |||
| #4 | |||
| #5 | |||
| #6 |
Chi-square test explained, step by step
A chi-square test compares observed frequencies against expected frequencies under H₀. Each card below covers one variant this calculator runs and the piece of the formula behind it.
1. What χ² measures — observed vs expected counts
Chi-square compares observed frequencies in categorical data against what H₀ predicts. Each cell contributes (O − E)² / E, so under- and over-counts both count as evidence and gaps are weighted by how big E is — a difference of 5 out of an expected 10 matters more than 5 out of 1000.
2. Goodness of fit — one categorical variable
Use this when you have counts across k categories and a hypothesised distribution (uniform, Poisson, historical proportions…). Degrees of freedom are k − 1 (subtract one more for every parameter you estimated from the data).
3. Test of independence — r × c contingency table
For two categorical variables cross-tabulated, expected counts come from the row and column marginals: Eᵢⱼ = Rᵢ·Cⱼ / N. Degrees of freedom are (r − 1)(c − 1) because once the top-left block is filled the rest is fixed by the totals.
4. When χ² breaks — small expected counts
The χ² approximation is unreliable when any expected count drops below about 5. Merge categories to raise expected counts, or use Fisher's exact test on 2×2 tables. Also use raw counts (not percentages) and remember χ² is an omnibus test — inspect cell contributions to see what's driving a significant result.
Features of this calculator
- Two tools in one page — goodness of fit and test of independence.
- Editable contingency table up to 6 × 6 with adjustable dimensions.
- Expected inputs accepted as either counts or proportions on the goodness-of-fit tool.
- Exact p-values from the χ² CDF (not table lookups).
- Critical value at your chosen α with a reject / fail-to-reject verdict in plain language.
- Shows the expected-frequency table beside the observed table, plus per-cell (O − E)²/E contributions.
- Warns when expected cell counts fall below 5, where the χ² approximation gets unreliable.
- Copy a text summary or download the results as a PNG.