Significance test

Chi-Square Goodness of Fit Calculator

The chi-square goodness of fit test checks whether the observed counts of a single categorical variable match an expected distribution — equal proportions by default, or any proportions you specify. It compares χ² = Σ (O − E)²/E to the chi-square distribution with k − 1 degrees of freedom.

Reviewed by the crosstabs.com methods team · Last updated

Run this on your own data — free, no signup

Upload a CSV or XLSX. Everything runs in your browser; your file never leaves your device.

Open the workspace →

Calculate online

Enter the observed count for each category. Leave “equal expected proportions” checked to test against a uniform distribution, or uncheck it to type your own expected counts or ratios (they are scaled to the observed total automatically).

Observed counts
CategoryObservedE (used)
33.33
33.33
33.33
Total100

Chi-square goodness of fit

14.00

df = 2 · p < .001 · the observed distribution differs significantly from the expected one

χ²(2, N = 100) = 14.00, p < .001

What the goodness of fit test tells you

Unlike the chi-square test of independence, which needs two variables in a contingency table, the goodness of fit test looks at one categorical variable and asks: do these counts plausibly come from the distribution I expected? Typical uses are checking whether a die is fair, whether customers are evenly split across plans, or whether a sample matches known population proportions.

A small p-value (conventionally below 0.05) means the observed distribution departs from the expected one by more than chance alone would explain.

Formula

Definition

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

Oᵢ
= the observed count in category i
Eᵢ
= the expected count in category i (n / k for equal proportions, or n × pᵢ for hypothesized proportions pᵢ)
k
= the number of categories
df
= k − 1 degrees of freedom; χ² is compared to the chi-square distribution

Worked example

Worked example

You roll a three-sided spinner 100 times and observe counts of [50, 30, 20]. If the spinner were fair you would expect 100 / 3 ≈ 33.33 in each category.

χ² = (50 − 33.33)²/33.33 + (30 − 33.33)²/33.33 + (20 − 33.33)²/33.33 = 14.00 with df = 3 − 1 = 2.

The p-value is p < .001 (about 0.0009), so the spinner is very unlikely to be fair — the categories are not equally likely.

When to use it

Use it when

  • You have one categorical variable and a hypothesized distribution (equal or specified proportions).
  • You want to check whether sample category frequencies match known population proportions.
  • All expected counts are at least 5 (or close to it), so the chi-square approximation holds.

Not the right tool when

  • You have two categorical variables and want to know if they are related — use the chi-square test of independence instead.
  • Many expected counts fall below 5 — combine sparse categories or use an exact multinomial test.
  • Your data are paired before/after measurements — see McNemar's test.

How to interpret it

Rule of thumb

Compare χ² to the chi-square distribution with k − 1 degrees of freedom. If p < 0.05, the observed counts differ significantly from the expected distribution; the largest (O − E)²/E contributions show which categories drive the misfit.

Frequently asked questions

Goodness of fit vs chi-square test of independence?
The goodness of fit test compares one categorical variable's observed counts to a hypothesized distribution (df = k − 1). The test of independence asks whether two categorical variables in a contingency table are related (df = (r − 1)(c − 1)). Both use the same χ² = Σ (O − E)²/E statistic, but the expected counts and degrees of freedom differ.
What if my expected counts don't sum to the observed total?
This calculator scales your expected values proportionally so they sum to the observed total. That means you can enter expected counts, percentages, or ratios (e.g. 1 : 2 : 3) — only the proportions matter.
How many categories can the test handle?
Any number from 2 upward (this calculator supports up to 20). With k categories the test has k − 1 degrees of freedom. Just keep the expected count in each category at 5 or more, otherwise the chi-square approximation becomes unreliable.
What does a low expected count warning mean?
The chi-square p-value is a large-sample approximation that breaks down when expected counts are small. The common rule of thumb is that all expected counts should be at least 5. If some fall below that, combine sparse categories or collect more data.

References & further reading

  • Pearson, K. (1900). On the criterion that a given system of deviations… Philosophical Magazine, 50(302), 157–175.
  • Goodness of fit — Wikipedia

Try it on your own data — free, no signup

Upload a CSV or XLSX. Everything runs in your browser; your file never leaves your device.

Open the workspace →

Related calculators

← All calculators & guides