Skip to content
K Knidox Search…
Statistics · Inference

Chi-Square Calculator

Goodness-of-fit test from observed and expected counts.

Comma or space separated.
Must match the number of observed values.
Examples — tap to load
χ² statistic
2.9p ≥ 0.05

df = 4 · p = 0.5747

The chi-square goodness-of-fit statistic is χ² = Σ (O − E)² ÷ E. A die rolled 60 times (10 expected per face) with observed 8, 12, 9, 11, 14, 6 gives χ² = 4.2 on 5 df — below the 11.07 critical value, so the die looks fair (p ≈ 0.52).

Does the data fit the expectation?

The chi-square goodness-of-fit test compares the counts you observed against the counts a hypothesis predicts. For each category it takes the gap between observed and expected, squares it, and scales by the expected count — so the same absolute gap matters more where few cases were expected. A large total χ² means the observed and expected distributions diverge more than chance alone would explain.

χ² = Σ (O − E)² ÷ E

summed over every category; df = number of categories − 1

Worked example

A die rolled 60 times, expected 10 per face. Observed: 8, 12, 9, 11, 14, 6.

  1. 1
    Find each category’s contribution. (O − E)² ÷ E: 0.4, 0.4, 0.1, 0.1, 1.6, 1.6 for the six faces.
  2. 2
    Sum them for χ². 0.4 + 0.4 + 0.1 + 0.1 + 1.6 + 1.6 = 4.2.
  3. 3
    Compare to the critical value. df = 6 − 1 = 5; the 0.05 critical χ² is 11.07. Since 4.2 < 11.07, the die looks fair (p ≈ 0.52).

Critical χ² values (α = 0.05)

Reject the null when χ² exceeds the value for your degrees of freedom.

dfCritical χ²Categories (df + 1)
13.8412
25.9913
37.8154
49.4885
511.0706

Setting it up and reading the result

Choose expected counts from the null. The expected counts come from whatever hypothesis you’re testing — equal proportions for a fair die, or known population rates for a “does our sample match?” question. They must sum to the same total as the observed counts.

Mind the minimum count rule. The χ² approximation assumes every expected count is at least 5. With sparse categories, combine them or use an exact test instead.

Use counts, not percentages. The test works on raw frequencies. Feeding it proportions or rates breaks the math — convert back to counts first.

Goodness-of-fit vs independence. This tool tests one categorical variable against a predicted distribution. For a contingency table testing whether two variables are related, first compute each expected cell as (row total × column total) ÷ grand total.

What expected counts should I use?
Whatever your null hypothesis predicts. For a fair die rolled 120 times, each face is expected 20 times; the expected counts must total the same as the observed counts.
Is there a minimum count?
A common rule of thumb is that every expected count should be at least 5 for the chi-square approximation to hold. Combine sparse categories if not.
Does this do tests of independence?
This tool covers the goodness-of-fit test. For a contingency table, compute expected counts as (row total × column total) ÷ grand total first, then enter those.
Can I use percentages instead of counts?
No. The test relies on raw frequencies, so convert any percentages back to actual counts before entering them.
What does a small p-value mean here?
It means the observed counts diverge from the expected distribution more than chance would readily produce — evidence the hypothesis doesn’t fit.
How are the degrees of freedom found?
For a goodness-of-fit test, df = number of categories − 1. Six die faces give 5 df, so the 0.05 critical χ² is 11.070.