Skip to content

Chi-Square Goodness of Fit Calculator

Type each category’s count and the share you expect for it, as percentages…

Type each category’s count and the share you expect for it, as percentages, ratios or counts, to test whether the data fit, with Mendel’s peas as the example.

CategoryObservedExpected share

exp 312.8

exp 104.3

exp 104.3

exp 34.8

Categories4 × 2 · names are editable

Expected shares can be percentages, a ratio (9, 3, 3, 1) or counts; they are scaled to your total. Leave them all empty to test equal shares.

Paste a table from a spreadsheet

Copy cells from Excel, Google Sheets or a CSV file and paste them here; the grid above follows.

ExampleP-value

0.9254

The counts fit the expected shares about as well as chance allows. Not significant at the 5% level (p ≥ 0.05).

Type your own counts, or paste a table.

315Round yellow108Round green101Wrinkled yell…32Wrinkled greenobservedexpected

The chi-square distribution with 3 df, what χ² looks like when nothing is going on; the shaded tail beyond yours is the p-value.

χ², df
0.47, 3
Total counted
556
Expected counts under 5
None
How this works: 9 sources,

How this works

Method

A goodness of fit test asks whether counts in categories match the shares a theory predicts: a fair die, an equal split between options, the ratios of a genetic cross, the expected mix of customers. The example is Gregor Mendel’s cross of round yellow peas with wrinkled green ones: 556 seeds against his predicted 9 : 3 : 3 : 1. Full method

How it’s tested

2 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.

Privacy

On your device. Nothing you enter or open leaves this browser. About privacy labels

Changes

  • First published: live curves with draggable cut-offs, and tests on pasted data (t-tests, ANOVA, chi-square, Fisher’s exact, correlation, regression, A/B), checked against SciPy.

Every change on What’s new

How we make toolsReport a mistake

How the chi-square goodness of fit test works

A goodness of fit test asks whether counts in categories match the shares a theory predicts: a fair die, an equal split between options, the ratios of a genetic cross, the expected mix of customers. The example is Gregor Mendel’s cross of round yellow peas with wrinkled green ones: 556 seeds against his predicted 9 : 3 : 3 : 1.

Turn the shares into expected counts by scaling them to the total (9/16 of 556 is 312.75), then add up (observed − expected)² ÷ expected over the categories. With k categories the statistic follows a chi-square distribution with k − 1 degrees of freedom when the theory is right. Mendel’s peas give χ² = 0.47 on 3 df, p = 0.93: an almost perfect fit.

A very high p-value is not proof the theory is right; it only means the data don’t contradict it. In fact Mendel’s results across his experiments fit so well that R. A. Fisher argued in 1936 they were better than chance would usually allow. If you estimate anything from the data to build the expected shares, take one more degree of freedom off for each.

Eᵢ = N × shareᵢ ÷ Σ shares · χ² = Σ (Oᵢ − Eᵢ)² ÷ Eᵢ, df = k − 1

Mendel’s 3 : 1 crosses tested

Mendel’s published counts for the second generation of his seven single-trait crosses, each tested against a 3 : 1 ratio (1 degree of freedom).

Mendel’s published counts for the second generation of his seven single-trait crosses, each tested against a 3 : 1 ratio (1 degree of freedom).
Trait (dominant : recessive)CountsRatioχ²p-value
Seed shape (round : wrinkled)5,474 : 1,8502.96 : 10.2630.608
Seed colour (yellow : green)6,022 : 2,0013.01 : 10.0150.903
Seed coat (grey : white)705 : 2243.15 : 10.3910.532
Pod shape (inflated : constricted)882 : 2992.95 : 10.0640.801
Pod colour (green : yellow)428 : 1522.82 : 10.4510.502
Flower position (axial : terminal)651 : 2073.14 : 10.350.554
Stem length (long : short)787 : 2772.84 : 10.6070.436

Common questions

How do I test whether a die is fair?

Type the six faces as categories with how often each came up, and leave the expected shares empty: equal shares are the default. With 60 rolls each face is expected 10 times.

Can the expected shares be percentages?

Yes: percentages, a ratio such as 9, 3, 3, 1, or expected counts all work, because they are scaled to your total. They just need to be in the same proportions as the theory.

What if some categories are rare?

Expected counts under 5 make the chi-square approximation shaky, and the page warns about them. Combine rare categories with neighbours, or collect more data.