Chi-square goodness of fit calculator

This chi-square goodness of fit calculator checks whether the counts in several categories match a distribution you expected. Paste the observed counts and the expected ratio, such as 9:3:3:1, or leave the expected values empty to test for equal frequencies.

Your numbers are calculated in your browser. Nothing you enter is sent or stored.

Chi-square goodness of fit calculatorOr describe it in Studio →

Expected values can be a ratio (9, 3, 3, 1), proportions (0.25, 0.75) or counts; they are scaled to the observed total. Leave empty to test against equal counts in every category.

The counts are consistent with the expected distribution (p = 0.9254).

CategoryObservedExpected(O − E)² ÷ E
1315312.750.016
2108104.250.135
3101104.250.101
43234.750.218
Chi-square
0.47
Degrees of freedom
3
p value
0.9254
Total
556

To report

χ²(3, N = 556) = 0.47, p = 0.9254

Check your result: the expected counts add up to the same total as the observed counts (556 in Mendel’s example), and the contributions add up to χ². The degrees of freedom are the number of categories minus 1, minus one more for each parameter estimated from the data.
χ² for Mendel’s 556 peas, df = 3
0.470
χ² for Mendel’s 556 peas, df = 3
p value of that fit
0.925
p value of that fit
χ² for 60 die rolls, p = 0.521
4.2
χ² for 60 die rolls, p = 0.521
  • Ratios, proportions or counts
  • Equal-frequency test by default
  • Contribution of each category
  • Warns on small expected counts
  • Runs in your browser, free

01

Goodness of fit formula

χ² = Σ (observed − expected)² ÷ expected

degrees of freedom = number of categories − 1

Expected counts are the expected proportions multiplied by the total number of observations. If you estimate a parameter from the data to get the expected values, subtract one more degree of freedom for each; the calculator does this when you set “Parameters estimated from the data”. Fitting a Poisson distribution with its mean taken from the sample is one estimated parameter.

07.815145%test statistic
A right-tail p value. Statistics such as chi-square, F and H can only be zero or positive, and larger values mean a worse fit to the null hypothesis. The p value is the area to the right of your statistic. The curve shown has 3 degrees of freedom; 5% of its area lies beyond 7.815.

02

Worked example: a 9:3:3:1 ratio

Mendel's dihybrid pea cross gave 315, 108, 101 and 32 seeds in the four classes, 556 in total.

ClassObservedExpected (9:3:3:1)(O − E)² ÷ E
Round yellow315312.750.016
Round green108104.250.135
Wrinkled yellow101104.250.101
Wrinkled green3234.750.218

χ² = 0.470, df = 3, p = 0.925

The counts fit the 9:3:3:1 ratio very closely.

03

Worked example: is a die fair?

Sixty rolls give 8, 12, 9, 11, 14 and 6. With a fair die each face is expected 10 times. χ² = 4.2 with 5 degrees of freedom, p = 0.521: there is no evidence the die is unfair.

04

Common mistakes with the goodness of fit test

  • Using percentages instead of counts. Mendel’s four classes as percentages (56.7, 19.4, 18.2, 5.8) give χ² = 0.074 instead of 0.470: the test then thinks about 100 seeds were counted, not 556.
  • Forgetting estimated parameters. A χ² of 7.0 with four categories has p = .072 on 3 degrees of freedom, but p = .030 on 2, the right number if one parameter came from the data.
  • Typing the ratio in the wrong order. Mendel’s counts against 1:3:3:9 instead of 9:3:3:1 give χ² = 2,512. Check that each ratio sits next to its class.

Trust

How this page is checked

  • The calculation runs on code with automated tests against worked reference values. Every number in the examples on this page was produced by that same code, not typed by hand.
  • The formulas and conventions used are stated on the page, so you can reproduce the result yourself or compare it with your own software.
  • Last reviewed by the Sciloom team, Zebra Nine Studio Inc. It is a tool for research and teaching, not a substitute for a statistician, a validated lab method or medical advice.

Cite this page

Sciloom. (2026). Chi-square goodness of fit calculator. Zebra Nine Studio Inc. https://sciloom.si/chi-square-goodness-of-fit-calculator

Read the full methodology · Who makes Sciloom

Frequently asked questions

What is the difference between goodness of fit and the test of independence?

Goodness of fit compares one categorical variable with a distribution you specify in advance. The test of independence asks whether two categorical variables are related, and takes its expected counts from the table margins.

Can I enter percentages instead of counts?

Observed values must be counts: the test depends on the sample size. Expected values can be percentages, proportions or a ratio.

How large must the expected counts be?

The usual guide is at least 5 in every category. Below that, combine categories or use an exact multinomial test.

What does a high p value mean here?

That the data give no reason to reject the expected distribution. It does not prove the distribution is correct, especially with a small sample.

Two variables in a table? Use the chi-square test of independence.
Free to start, no sign-up.
Back to the tool ↑

More research tools