Skip to content
Omnikalc

Chi-square goodness of fit: do your counts match the expected distribution?

Compare observed counts in up to six categories with equal or custom expected proportions: chi-square statistic, degrees of freedom, p-value and effect size.

Updated on
Your inputs
Expected distribution

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

%

Value out of range

%

Value out of range

%

Value out of range

%

Value out of range

%

Value out of range

%

Value out of range

Value out of range

Results

p-value

0.01991

Significant: the counts do not fit the expected distribution
Chi-square statistic χ²
13.400
Degrees of freedom
5
Critical χ² at α
11.070
Total count N
60
Smallest expected count
10.00
All expected counts are at least 5
Effect size, Cohen's w = √(χ² ÷ N)
0.473

What the goodness-of-fit test does

The chi-square goodness-of-fit test checks whether observed counts in several categories match an expected distribution. Is a die fair? Do customers arrive equally on each weekday? Do genetic crosses follow Mendel’s 9:3:3:1 ratio? Does a sample match the age profile of the census? In each case you compare what you counted with what a hypothesis predicts.

The formula

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

  • O: observed count in each category;
  • E: expected count = N × expected proportion.

Under the null hypothesis that the data follow the expected distribution, χ² follows a chi-square distribution with k − 1 − m degrees of freedom, where k is the number of categories and m the number of parameters estimated from the data (0 when the expected proportions are fixed in advance).

Example

A die is rolled 60 times and shows 5, 8, 9, 8, 10 and 20 for faces one to six. If the die is fair, each face is expected 10 times:

  • χ² = (25 + 4 + 1 + 4 + 0 + 100) ÷ 10 = 13.4, with 5 degrees of freedom;
  • p ≈ 0.020: significant at α = 0.05; the critical χ² is 11.07;
  • Cohen’s w ≈ 0.47, a large effect, driven mostly by the twenty sixes.

Custom proportions

Choose “custom proportions” and enter the expected share of each category, in percent. The shares are rescaled if they do not add up exactly to 100. For a 9:3:3:1 genetic ratio, enter 56.25, 18.75, 18.75 and 6.25.

Conditions of use

  • Observations are independent, and each falls into exactly one category.
  • Use counts, not percentages or means.
  • Expected counts should be at least 5 in every category (some authors accept a few between 1 and 5 if most are above 5). Otherwise, merge neighboring categories or use an exact multinomial test.

Effect size and interpretation

With large samples, tiny deviations become significant. Cohen’s w = √(χ² ÷ N) helps judge practical importance: about 0.1 is small, 0.3 medium and 0.5 large. To see which categories drive the result, look at the standardized residuals (O − E) ÷ √E; values beyond about ±2 stand out.

  • Testing whether two categorical variables are associated in a contingency table is the chi-square test of independence, which uses (rows − 1) × (columns − 1) degrees of freedom.
  • For two categories, the goodness-of-fit test is equivalent to a two-sided test of one proportion.

Frequently asked questions

How many degrees of freedom does a goodness-of-fit test have?

The number of categories minus 1, minus the number of parameters estimated from the data.

What is the minimum expected count for a chi-square test?

At least 5 in every category is the usual rule; otherwise merge categories or use an exact test.

Can I use percentages in a chi-square test?

No. The test must use raw counts; percentages hide the sample size.

How do I test whether a die is fair?

Roll it many times, count each face and compare with equal expected counts using 5 degrees of freedom.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.