Enter your observed counts alongside what you expected. The calculator reports the chi-square statistic, its p value, and which category contributed most — usually the most interesting part of the result.
| Observed count | Expected | Remove |
|---|---|---|
One row per category. Expected may be counts, ratios (1, 1, 2) or percentages — they are rescaled to your observed total either way. Leave the column as-is for an equal-frequency test.
Show the working, step by step
The formula
χ² = Σ (O − E)² ÷ E
For each category, take the gap between observed and expected, square it so direction does not cancel out, and divide by the expected count. Add the results across categories.
That division is what makes the statistic work. Without it, a discrepancy of 20 would count the same whether you expected 25 or 25,000. Scaling by the expected count turns the raw gap into a relative one, which is what "surprising" actually means here.
A worked example
Sixty rolls of a die, testing whether it is fair. Each face is expected 10 times:
| Face | Observed | Expected | (O − E)² ÷ E |
|---|---|---|---|
| 1 | 8 | 10 | 0.4 |
| 2 | 12 | 10 | 0.4 |
| 3 | 9 | 10 | 0.1 |
| 4 | 14 | 10 | 1.6 |
| 5 | 7 | 10 | 0.9 |
| 6 | 10 | 10 | 0.0 |
| Total | 60 | 60 | 3.4 |
χ² = 3.4 with 5 degrees of freedom gives p ≈ 0.64. Nothing unusual here: a fair die produces a pattern at least this uneven about two thirds of the time. The critical value at 5% would be 11.07, and 3.4 is nowhere near it.
Why the test is always one-tailed
χ² is a sum of squared terms, so it cannot be negative, and every departure from expectation — in either direction — makes it larger. Only the upper tail is evidence against the null hypothesis. There is no such thing as a two-tailed chi-square test in this setting.
A curiosity worth knowing: a chi-square that is suspiciously small means the data fits expectation far better than random sampling should allow. Fisher used exactly this argument to suggest Mendel's pea data had been tidied up.
Reading the contributions
The total statistic tells you whether something is off. The per-category contributions tell you where, and that is usually the finding you actually report. A single category supplying most of the total points straight at the anomaly; contributions spread evenly suggest the whole distribution is gently misspecified.
What the test assumes
- Counts, not percentages or means. Chi-square operates on frequencies. Converting percentages back to counts first is essential — the sample size is doing real work in the formula.
- Independent observations. Each observation falls in exactly one category, and one observation's category does not affect another's.
- Expected counts of at least 5 in essentially every cell. The usual guidance allows a few cells slightly below, provided none is near zero.
- Mutually exclusive, exhaustive categories. Every observation must be counted once and only once.
Effect size
Chi-square scales with the sample. Double every count and the statistic doubles while the pattern is identical — so a large χ² on a large dataset says very little on its own. Cohen's w divides it back out:
w = √(χ² ÷ n)
Conventionally 0.1 is small, 0.3 medium and 0.5 large. Report it beside the p value, for the same reason a t-test should be reported with Cohen's d.
Common questions
What does a chi-square test do?
It compares counts you observed against counts you would have expected, and asks whether
the gaps are bigger than chance would produce. Every category contributes
(observed − expected)² ÷ expected, and those contributions add up to the
statistic.
Dividing by the expected count is the key step: a gap of 5 is remarkable when you expected 10 and unremarkable when you expected 1000.
What is the difference between goodness of fit and independence?
Goodness of fit compares one set of counts against a hypothesised distribution — is this die fair, do these proportions match the theoretical 9:3:3:1? That is the test on this page.
Independence uses a two-way contingency table and asks whether two classifications are related — is treatment response associated with which treatment was given? Its expected counts come from the row and column totals.
How do I enter expected values?
Any way that expresses the right proportions. Counts, ratios or percentages all work —
they are rescaled to your observed total automatically, so entering 1, 1, 2 is
the same as entering 25, 25, 50.
For an equal-frequency test, leave the expected column matching across every row, or set them all to the same number.
Why does an expected count below 5 matter?
Because chi-square is a continuous approximation to what is really a discrete count problem, and the approximation degrades when expected counts are small. Below about 5 the p value becomes unreliable — usually too small, so you over-reject.
The usual remedies are to merge sparse categories into a sensible larger one, or to use an exact test. The calculator warns you when any expected count falls below the threshold.
How many degrees of freedom does the test have?
For goodness of fit, the number of categories minus one. One is subtracted because the expected counts are constrained to sum to the observed total — once you know all but the last category, the last is determined.
For a contingency table it is (rows − 1) × (columns − 1), for the same reason applied in both directions.
Can chi-square tell me how strong the association is?
Not on its own — the statistic grows with the sample size even when the pattern is unchanged, so a big chi-square can mean a big effect or just a big dataset. Effect sizes fix this by normalising it: Cohen's w for goodness of fit, Cramér's V for a contingency table. Both are reported above.
Related calculators
-
P-value calculator
Convert a chi-square statistic and df into p.
-
T-test calculator
For comparing means rather than counts.
-
Binomial distribution
Exact probabilities for two-outcome counts.
-
ANOVA calculator
Three or more group means at once.