Tools & Calculators
Practice
Tools & Calculators

Chi-Square Calculator (Goodness of Fit, with Steps)

Enter what you observed and what you expected, as counts or as a ratio like 3:1 or 9:3:3:1, and this chi-square calculator gives you χ², the degrees of freedom, the critical value and whether to reject the null hypothesis, with every step shown.

Loading the chi-square calculator…

How to use the chi-square calculator

  1. Choose how you’ll give the expected values: A ratio (such as 3:1 for a monohybrid cross or 9:3:3:1 for a dihybrid cross) or Expected counts.
  2. Add a row for each category, with its observed count and its ratio part or expected count. Names are optional.
  3. Pick a significance level. Most biology classes use p = 0.05.
  4. Read χ² and the verdict at the top, then the table and steps below it.

Worked example: Mendel’s peas

In one of Mendel’s dihybrid crosses, the offspring were 315 round yellow, 108 round green, 101 wrinkled yellow and 32 wrinkled green: 556 in all. The null hypothesis is that the genes assort independently, so the offspring should follow a 9:3:3:1 ratio.

Phenotype Observed Expected (O − E)² ÷ E
Round yellow 315 556 × 9/16 = 312.75 0.016
Round green 108 556 × 3/16 = 104.25 0.135
Wrinkled yellow 101 556 × 3/16 = 104.25 0.101
Wrinkled green 32 556 × 1/16 = 34.75 0.218

Add the last column: χ² = 0.470. There are 4 categories, so df = 3, and the critical value at p = 0.05 is 7.81. Since 0.470 is far below 7.81, we fail to reject the null hypothesis. Mendel’s data fit 9:3:3:1 very well.

What the chi-square test tells you

Real data never match a prediction exactly. Flip a coin 100 times and you might get 54 heads, not 50. The chi-square test asks whether the difference between what you observed and what you expected is small enough to be chance, or big enough that something else is probably going on.

The formula adds up one value per category:

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

Squaring the difference makes every term positive, so differences above and below expected can’t cancel out. Dividing by E scales each difference to the size of the category: being off by 10 matters a lot when you expected 20 and very little when you expected 2,000.

A χ² of 0 means a perfect match. The bigger χ² gets, the less likely it is that chance alone explains the data.

The null hypothesis

Every chi-square test starts with a null hypothesis that predicts the expected values. In genetics, it’s usually “the cross follows Mendelian ratios,” such as 3:1 or 1:2:1. In an animal behavior lab, it might be “the pill bugs have no preference between the wet and dry sides,” which predicts a 50:50 split.

The test never proves the null hypothesis true. “Fail to reject” means the data are consistent with it, not that it’s certainly right.

Degrees of freedom and the critical value

For a goodness-of-fit test, the degrees of freedom are the number of categories minus 1. Once you know all but one category and the total, the last one is fixed, so it isn’t free to vary.

The critical value is the χ² that chance alone would beat only 5% of the time (at p = 0.05). Here are the values from the AP® Biology formula sheet:

p df 1 df 2 df 3 df 4 df 5
0.05 3.84 5.99 7.81 9.49 11.07
0.01 6.63 9.21 11.34 13.28 15.09

If χ² is greater than the critical value, reject the null hypothesis: the difference is statistically significant. If it’s less, fail to reject it.

Common mistakes

  • Using percentages instead of counts. Chi-square needs the actual number of individuals. 60% of 10 and 60% of 1,000 give very different results.
  • Getting df wrong. It’s categories minus 1, not the number of individuals minus 1.
  • Expected counts that don’t add to the total. The expected counts should add to the same number as the observed counts. The calculator warns you if they don’t.
  • Small expected counts. If any expected count is below 5, the test isn’t reliable. Combine categories or collect more data.
  • Saying the hypothesis is “proven.” On the AP exam, write “fail to reject the null hypothesis,” and say what it means in context.

Chi-square on the AP® Biology exam

Expect a free-response question that gives you a table of offspring or lab counts. You’ll state a null hypothesis, calculate χ², find the degrees of freedom, compare against the formula sheet’s critical value at p = 0.05, and explain your conclusion. Showing the setup (O, E and each term) earns points even if you slip on arithmetic, so the table format above is worth copying.

In AP® Statistics the same test is called a chi-square goodness-of-fit test, and you’ll usually report a p-value along with the conclusion. The calculator shows both.

Keep practicing

Chi-square calculator FAQ

How do you calculate chi-square?

For each category, subtract the expected count from the observed count, square it, and divide by the expected count. Add those values for every category. The total is χ².

How do I find the degrees of freedom?

For a goodness-of-fit test, degrees of freedom are the number of categories minus 1. A dihybrid cross with four phenotypes has 3 degrees of freedom.

What does it mean to reject the null hypothesis?

If χ² is greater than the critical value, the gap between observed and expected is too big to blame on chance at that significance level. If it’s smaller, you fail to reject: the data fit the expected ratio well enough.

What is the critical value for p = 0.05?

It depends on degrees of freedom: 3.84 for df = 1, 5.99 for df = 2, 7.81 for df = 3, 9.49 for df = 4 and 11.07 for df = 5. These match the AP® Biology formula sheet.