InfyCalculator
📊

Chi-Square Goodness-of-Fit Calculator

Test whether observed counts match an expected distribution with the chi-square goodness-of-fit statistic, degrees of freedom and p-value.

Observed counts
Expected counts
Loading calculator…

How it works

χ² = Σ (Observed − Expected)² ÷ Expected · df = k − 1

The goodness-of-fit test checks whether a single categorical variable follows a claimed distribution. For each category it squares the gap between the observed and expected counts and scales it by the expected count, then sums across categories. A large χ² means the observed pattern strays far from expectations; the p-value from the chi-square distribution with k − 1 degrees of freedom says how surprising that is.

Worked example

Expected counts of 40, 30, 20, 11 versus observed 48, 35, 15, 3 give contributions 64/40 + 25/30 + 25/20 + 64/11 = 1.6 + 0.83 + 1.25 + 5.82 = 9.5. On 3 degrees of freedom that χ² of about 9.5 has p ≈ 0.023, so we reject the claimed distribution at the 5% level.

Sources: Goodness of fit — Wikipedia

Frequently asked questions

How many degrees of freedom does this test have?

For a plain goodness-of-fit test it is the number of categories minus one. If you also estimated parameters of the expected distribution from the data, subtract one more for each estimated parameter.

What is the small expected-count rule?

The chi-square approximation works best when every expected count is at least 5. With smaller expected counts, combine categories or use an exact test such as the multinomial or Fisher’s exact test.

Does the test use observed or expected counts in the denominator?

Always the expected count. Each term is (observed − expected)² divided by expected, which weights categories by how many cases the model predicted for them.

Related calculators

For education — check the assumptions (sample size, independence, distribution) before using these statistics in real decisions.