Chi-square goodness-of-fit test

Is a die fair? Do customers choose the four menus equally often? Do your genotype counts match 1 : 2 : 1? Enter the observed counts and, if they are not all equal, the expected counts or proportions to get Pearson's χ² statistic, the p-value and the contribution of each category.

One count per category, separated by commas, spaces or semicolons.
Optional. Counts, proportions (0.25) or percentages (25); they are scaled to the observed total. Empty means all categories equally likely.
Usually 0. Each parameter estimated from the same data (for example a mean for a Poisson fit) removes one degree of freedom.
Between 0 and 1, usually 0.05.
χ²8.1
p-value0.1508
Result at α
p ≥ α: no significant difference from the expected distribution
Degrees of freedom
5
Critical value at α
11.0705
Total count
120
Effect size w = √(χ²/n)
0.259808
Observed, expected and contribution of each category
1: O = 18 E = 20 (O − E)²/E = 0.2 2: O = 22 E = 20 (O − E)²/E = 0.2 3: O = 16 E = 20 (O − E)²/E = 0.8 4: O = 25 E = 20 (O − E)²/E = 1.25 5: O = 12 E = 20 (O − E)²/E = 3.2 6: O = 27 E = 20 (O − E)²/E = 2.45

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Enter the observed count of each category, for example 18, 22, 16, 25, 12, 27 for 120 rolls of a die.
  2. Leave the expected box empty for equal chances, or enter the expected counts or proportions in the same order.
  3. Read χ², the p-value and the decision; the table shows which categories contribute most.

How it works

The expected values are scaled to the observed total n: Eᵢ = n · eᵢ / Σe. Then

χ² = Σ (Oᵢ − Eᵢ)²/Eᵢ, df = k − 1 − m

with k categories and m estimated parameters. The p-value is P(χ²_df ≥ χ²), the upper tail of the chi-square distribution, and the critical value is the χ² that leaves α in that tail.

Worked example

A die rolled 120 times shows 18, 22, 16, 25, 12 and 27. If it is fair, each face is expected 20 times. The contributions are 0.2, 0.2, 0.8, 1.25, 3.2 and 2.45, so χ² = 8.1 with df = 5. The p-value is 0.1508, above 0.05 (the critical value is 11.0705), so the data give no evidence that the die is unfair. The effect size w is 0.259808.

Tips and common mistakes

  • Use counts, not percentages, for the observed values: the test depends on the sample size.
  • Every observation must fall into exactly one category, and observations must be independent.
  • Expected counts below 5 make the p-value unreliable; combine neighbouring categories if you can.

Frequently asked questions

What is the formula of the chi-square goodness-of-fit test?

χ² = Σ (O − E)²/E over all categories, where O is the observed and E the expected count. Under the null hypothesis it follows a chi-square distribution with k − 1 degrees of freedom (k categories), minus one more for each parameter estimated from the data.

Can I enter percentages as the expected values?

Yes. The expected values are rescaled so they add up to the observed total, so 25, 50, 25 and 0.25, 0.5, 0.25 and 1, 2, 1 all mean the same thing.

What does a significant result mean?

That counts this far from the expected ones would be unlikely if the expected distribution were true. Look at the category contributions to see where the misfit comes from.

How is it different from the chi-square test of independence?

The goodness-of-fit test compares one categorical variable with a given distribution. The test of independence compares two variables in a contingency table; use the chi-square calculator for that.

More in Math

All tools in this category: Math ·Updated November 4, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.