🧮
🧮 Math & statistics

Chi-Square Goodness-of-Fit Calculator

Results update as you type.

Your numbers

Understanding the chi-square goodness-of-fit test — concept and principle

The chi-square goodness-of-fit test asks whether the counts you observed in several categories are consistent with a distribution you specified in advance. Examples: is a die fair, are customers spread evenly across weekdays, do genetic offspring follow a 3 : 1 ratio. Enter the observed counts and, optionally, the expected counts or proportions; leave expected blank to test for equal frequencies.

Goodness-of-fit: five observed counts against an expected 20 eachCounts 18, 22, 20, 25, 15 against 20 each give terms 0.2, 0.2, 0, 1.25, 1.25, so chi-square is 2.9 with 4 df and p about 0.57.Do the counts fit an even split?expected: 100 ÷ 5 = 20 in each day18Mon0.222Tue0.220Wed025Thu1.2515Fri1.25E = 20(O − E)² ÷ E per day: 0.2 + 0.2 + 0 + 1.25 + 1.25χ² = 58 ÷ 20 = 2.9 · df 4p ≈ 0.57 → no sign of misfit
The gaps from 20 add up to χ² = 2.9 on 4 df — well within chance (p ≈ 0.57).

How it is calculated

  1. Expected values are scaled so that they add up to the observed total: E_i = (your expected value_i ÷ sum of expected values) × N. With a blank field, every E_i = N ÷ k.
  2. χ² = Σ (O_i − E_i)² ÷ E_i over all k categories.
  3. df = k − 1, because once the total is fixed only k − 1 counts are free.
  4. The p-value is the upper-tail probability of the chi-square distribution with k − 1 df.

Because of the scaling step you may type expected values as counts, percentages or ratios such as 3, 1.

The principle

Each term (O − E)² ÷ E measures how far one category strays from its expected count, relative to the size of that count. Under the null hypothesis the counts behave roughly like independent Poisson-type variation around E, so each standardised gap is approximately a squared standard normal value; adding them gives a chi-square variable. One degree of freedom is lost because the counts must sum to N. If you estimated parameters of the expected distribution from the same data, subtract one more df for each parameter; this calculator does not do that automatically.

Worked example

  1. Observed: 18, 22, 20, 25, 15, so N = 100 and k = 5.
  2. Expected is blank, so each E = 100 ÷ 5 = 20.
  3. Squared gaps: 4, 4, 0, 25, 25, total 58.
  4. χ² = 58 ÷ 20 = 2.9.
  5. df = 5 − 1 = 4.
  6. Upper tail of χ² with 4 df beyond 2.9: p ≈ 0.5747.

How to read the result

A large p-value, as here, means the deviations are well within what chance alone produces, so there is no evidence against the equal-frequency model. It does not prove the model is true. A p-value below your significance level (often 0.05) suggests the data do not fit. For reference, the 5% critical value is 3.84 for 1 df, 5.99 for 2 df and 9.49 for 4 df. Compare the individual (O − E)² ÷ E terms to see where a misfit comes from.

Common mistakes

Keep in mind: The p-value relies on a large-sample approximation. Keep every expected count at about 5 or more, or merge sparse categories before testing; for very small samples use an exact multinomial or binomial test.

Frequently asked questions

Can I test unequal expected proportions?

Yes. Type them in the expected field in the same category order, for example 3, 1 for a 3 : 1 ratio; they are rescaled to your total.

Why does a bigger sample make small differences significant?

χ² grows roughly in proportion to N for the same percentage gaps, so with very large samples even trivial deviations give small p-values.

Sources: Pearson, K. (1900). Philosophical Magazine, 50(302), 157–175. · Agresti, A. An Introduction to Categorical Data Analysis (Wiley).

Checked 8 Nov 2026. Standard formulas, computed in your browser with double-precision numbers.

🧮 All math & statistics tools →🌍 Calculators by country →