AP · Biology · Mendelian Genetics

The Chi-Square Test

13 min readUpdated November 30, 2026FreeAP Biology, Heredity

The chi-square (χ2\chi^2) test tells you whether the gap between observed counts and the counts a hypothesis predicts is small enough to be due to chance. You state a null hypothesis, calculate the expected counts, find χ2\chi^2, and compare it with the critical value for your degrees of freedom: if χ2\chi^2 is larger, you reject the null hypothesis.

Quick check

  1. What phenotype ratio do you expect from a cross of two heterozygotes, Aa × Aa?Show answerHide answer

    3 dominant : 1 recessive.

  2. A cross predicts 3:1. How many of 200 offspring should be recessive?Show answerHide answer

    One quarter of 200, which is 50.

Know these already? Jump to the practice questions

What you'll be able to do

  • State the null hypothesis for a set of count data.
  • Calculate expected values from a predicted ratio.
  • Calculate χ2\chi^2 and the degrees of freedom.
  • Decide whether to reject the null hypothesis and explain what that means.

Key terms

Null hypothesis

The hypothesis that there is no real difference between the observed and expected results, so any difference is due to chance.

In plain English
Nothing is going on except chance.
Don't write
"The null hypothesis is that the data are wrong."

Expected value

The count a hypothesis predicts for one category: the predicted proportion times the total count.

In plain English
What a perfect fit would look like.
Don't write
"The expected value is the ratio number, such as 3."

Degrees of freedom

The number of categories minus one.

In plain English
Once all but one count is known, the last is fixed by the total.
Don't write
"The number of individuals minus one."

Critical value

The χ2\chi^2 value from the table, for your degrees of freedom and probability level, that your χ2\chi^2 must exceed for you to reject the null hypothesis.

In plain English
The cut-off line.
Don't write
"Below the critical value, the hypothesis is proved."

What does the chi-square test decide?

Real counts rarely match a ratio exactly, because which gametes meet is random. The test asks whether the difference is small enough to be chance:

  1. State the null hypothesis: there is no significant difference between observed and expected counts.
  2. Measure the size of the difference as χ2\chi^2: the bigger the gaps between observed and expected, the bigger χ2\chi^2.
  3. Ask how likely a χ2\chi^2 that large would be if the null hypothesis were true. The usual level is p = 0.05: if chance alone would give a value this large less than 5 per cent of the time, the difference is called significant.

A significant result means something besides chance is probably affecting the counts, such as linked genes.

Check yourself

For a 9:3:3:1 dihybrid cross, state the null hypothesis.
Show answerHide answer

There is no significant difference between the observed counts and the counts expected from a 9:3:3:1 ratio; any difference is due to chance.

How do you calculate χ2\chi^2?

On the AP® Biology formula sheet:

χ2=∑(o−e)2e\chi^2 = \sum \frac{(o - e)^2}{e}

where o is the observed count and e the expected count for each category. Work in a table:

  1. Expected count = predicted fraction × total. For a 3:1 ratio with 400 offspring: 34×400=300\dfrac{3}{4} \times 400 = 300 and 14×400=100\dfrac{1}{4} \times 400 = 100.
  2. For each category, find o−eo - e, square it, and divide by e.
  3. Add the results.
Categoryoe(o−e)2e\dfrac{(o-e)^2}{e}
Dominant3123000.48
Recessive881001.44
Total400400χ2=1.92\chi^2 = 1.92

Squaring stops positive and negative gaps cancelling; dividing by e scales each gap to its category's size.

Check yourself

In one category, o = 45 and e = 50. What does this category add to χ2\chi^2?
Show answerHide answer

(45−50)2÷50=25÷50=0.5(45 - 50)^2 \div 50 = 25 \div 50 = 0.5.

How do you decide whether to reject the null hypothesis?

  1. Degrees of freedom = number of categories − 1.
  2. Read the critical value for that df at p = 0.05 from the table (on the AP® Biology formula sheet).
  3. If χ2\chi^2 is greater than the critical value, reject the null hypothesis: the difference is significant. If not, fail to reject it: the difference can be explained by chance.
Degrees of freedom12345
Critical value, p = 0.053.845.997.819.4911.07
Critical value, p = 0.016.639.2111.3413.2815.09

For the table in the previous section: 2 categories, so df = 1; 1.92<3.841.92 < 3.84, so you fail to reject the null hypothesis, and the data are consistent with a 3:1 ratio.

Examiner's eye

Marks go to the full statement: the null hypothesis, df, the critical value, the comparison, the decision, and what it means biologically.

Check yourself

A test with 4 categories gives χ2=8.2\chi^2 = 8.2. Do you reject the null hypothesis at p = 0.05?
Show answerHide answer

Yes. df = 3, the critical value is 7.81, and 8.2 is greater, so the difference is significant.

Worked example 1: Mendel's dihybrid data

Question: In his 1866 paper, Gregor Mendel reported that self-pollinated pea plants heterozygous for seed shape and seed color (RrYy) produced 315 round yellow, 108 round green, 101 wrinkled yellow and 32 wrinkled green seeds. Test whether these counts fit a 9:3:3:1 ratio at p = 0.05. Calculate χ2\chi^2 to two decimal places.

What tells you the method

Counts in categories and a predicted ratio: a chi-square test.

  1. Step 1: State the null hypothesis.

    There is no significant difference between the observed counts and a 9:3:3:1 ratio.

    Why

    The test starts from "any difference is chance".

  2. Step 2: Find the expected counts.

    Total =556= 556; expected =916,316,316,116= \dfrac{9}{16}, \dfrac{3}{16}, \dfrac{3}{16}, \dfrac{1}{16} of 556 =312.75,104.25,104.25,34.75= 312.75, 104.25, 104.25, 34.75.

    Why

    Expected count = predicted fraction × total.

  3. Step 3: Calculate χ2\chi^2.

    Seedsoe(o−e)2e\dfrac{(o-e)^2}{e}
    Round yellow315312.750.016
    Round green108104.250.135
    Wrinkled yellow101104.250.101
    Wrinkled green3234.750.218

    χ2=0.47\chi^2 = 0.47.

    Why

    Each category's squared gap is divided by its own expected count, then all four are added.

  4. Step 4: Compare and decide.

    df =4−1=3= 4 - 1 = 3, critical value 7.81. 0.47<7.810.47 < 7.81, so fail to reject the null hypothesis.

    Why

    A χ2\chi^2 this small would arise by chance far more often than 5 per cent of the time.

Check it

The expected counts add to 556, and every gap is under 4 seeds, so a small χ2\chi^2 makes sense.

Answer

χ2=0.47\chi^2 = 0.47; fail to reject the null hypothesis, so the data are consistent with 9:3:3:1 and with independent assortment of the two genes.

Worked example 2: A choice-chamber investigation

Question: In a class investigation, 30 pill bugs were placed in a choice chamber with a moist side and a dry side. After 10 minutes, 22 were on the moist side and 8 on the dry side. The null hypothesis is that pill bugs show no preference. Calculate χ2\chi^2 to two decimal places, then decide at p = 0.05. Answer reject or fail to reject.

What tells you the method

Counts in two categories and a "no preference" prediction.

  1. Step 1: Find the expected counts.

    No preference means half on each side: e=15e = 15 and 15.

    Why

    The null hypothesis predicts a 1:1 split of the 30 animals.

  2. Step 2: Calculate χ2\chi^2.

    (22−15)215+(8−15)215=4915+4915=6.53\dfrac{(22 - 15)^2}{15} + \dfrac{(8 - 15)^2}{15} = \dfrac{49}{15} + \dfrac{49}{15} = 6.53.

    Why

    Each side contributes its squared gap over its expected count.

  3. Step 3: Compare and decide.

    df =2−1=1= 2 - 1 = 1, critical value 3.84. 6.53>3.846.53 > 3.84, so reject the null hypothesis.

    Why

    A split this uneven would happen by chance less than 5 per cent of the time if there were no preference.

Check it

22 + 8 = 30, and the two gaps are equal in size (7), as they must be with two categories.

Answer

χ2=6.53\chi^2 = 6.53; reject the null hypothesis. The difference is significant, which supports a preference for the moist side.

Your turn

Question: A cross predicts a 3:1 ratio. Of 400 offspring, 290 show the dominant phenotype and 110 the recessive. Calculate χ2\chi^2 to two decimal places, then decide at p = 0.05. Answer reject or fail to reject.

  1. Step 1: Expected counts.

    34×400=300\dfrac{3}{4} \times 400 = 300 and 14×400=100\dfrac{1}{4} \times 400 = 100.

  2. Step 2: Your go: calculate χ2\chi^2, then compare it with the critical value for df = 1.

Show the full solutionHide the solution

Step 2. (290−300)2300+(110−100)2100=0.33+1.00=1.33\dfrac{(290 - 300)^2}{300} + \dfrac{(110 - 100)^2}{100} = 0.33 + 1.00 = 1.33. With df = 1, the critical value is 3.84, and 1.33<3.841.33 < 3.84.

Answer: χ2=1.33\chi^2 = 1.33; fail to reject the null hypothesis, so the data are consistent with 3:1.

Traps

Trap

Failing to reject the null hypothesis proves the hypothesis is true.

It seems right because the data "passed" the test. But the test only shows that the difference could be due to chance: the data are consistent with the prediction, and another hypothesis might fit them too.

A cross gives χ2\chi^2 below the critical value for a 3:1 ratio. Has the test proved the trait is controlled by one gene with two alleles?

No. It shows only that the data are consistent with 3:1. Say "fail to reject the null hypothesis", not "proved".

Trap

You can put percentages or ratio numbers into the formula in place of counts.

It seems right because the prediction is written as a ratio. But χ2\chi^2 depends on sample size, so o and e must both be actual counts of individuals.

Predicted ratio 3:1, 80 offspring. Should e for the dominant class be 3, 75 or 60?

60, because 34×80=60\dfrac{3}{4} \times 80 = 60. The value 3 is a ratio number and 75 is a percentage; neither is a count.

What's examined

On the AP® Biology exam (Unit 5: Heredity, and wherever count data appear), expect to state a null hypothesis, calculate expected values, χ2\chi^2 and df, compare with the critical value, and explain the result. A calculator is allowed.

Practice questions

  1. Recall A student crosses two heterozygous plants and predicts a 3:1 ratio. Which is the null hypothesis?
  • A) The offspring will show exactly a 3:1 ratio.
  • B) There is no significant difference between the observed counts and a 3:1 ratio; any difference is due to chance.
  • C) The observed counts differ significantly from a 3:1 ratio.
  • D) The recessive allele is less common than the dominant allele.
Show answer

Answer: B. The null hypothesis says the prediction holds and any difference is chance.

Why the others are wrong:

  • A: Real counts are not expected to match a ratio exactly.
  • C is the alternative hypothesis.
  • D is about allele frequency, not the fit of the counts.
  1. Recall A chi-square test compares counts with a 9:3:3:1 ratio. How many degrees of freedom does it have?
Show answer

Answer: 3 degrees of freedom.

Marking points:

  • Four phenotype categories, so df = 4 − 1 = 3.
  1. Apply A cross is predicted to give genotypes in a 1:2:1 ratio. Of 240 offspring, calculate the expected number of heterozygotes.
Show answer

Answer: 120 heterozygotes.

Marking points:

  • Heterozygotes are 2 of the 4 parts: 24×240=120\dfrac{2}{4} \times 240 = 120.
  1. Apply A cross is predicted to give a 3:1 ratio. Of 160 offspring, 128 are dominant and 32 recessive.

(a) Calculate χ2\chi^2 to two decimal places.

(b) Decide at p = 0.05. Answer reject or fail to reject.

Show answer

Answer: (a) χ2=2.13\chi^2 = 2.13; (b) fail to reject the null hypothesis.

Marking points:

  • Expected: 120 dominant and 40 recessive.
  • (128−120)2120+(32−40)240=0.53+1.60=2.13\dfrac{(128 - 120)^2}{120} + \dfrac{(32 - 40)^2}{40} = 0.53 + 1.60 = 2.13.
  • df = 1, critical value 3.84; 2.13<3.842.13 < 3.84, so the difference can be explained by chance.
  1. Exam-style A dihybrid cross predicted to give 9:3:3:1 gives χ2=9.2\chi^2 = 9.2. Which conclusion is correct at p = 0.05?
  • A) Fail to reject the null hypothesis, because 9.2 is less than the critical value for df = 4.
  • B) Fail to reject the null hypothesis, because a large χ2\chi^2 means a good fit.
  • C) Reject the null hypothesis, because 9.2 is greater than 3.84.
  • D) Reject the null hypothesis, because 9.2 is greater than 7.81.
Show answer

Answer: D. Four categories give df = 3, whose critical value is 7.81, and 9.2 exceeds it, so something besides chance, such as linkage, may be affecting the counts.

Why the others are wrong:

  • A uses df = 4 (the number of categories) instead of 3.
  • B reverses the meaning: a large χ2\chi^2 means a poor fit.
  • C reaches the right decision with the critical value for df = 1.
  1. Exam-style A student's χ2\chi^2 is 1.9 with df = 1. Which statement is the best conclusion at p = 0.05?
  • A) The difference can be explained by chance, so the data are consistent with the predicted ratio.
  • B) The predicted ratio has been proved correct.
  • C) The difference is significant, so the predicted ratio is wrong.
  • D) The test cannot be used because χ2\chi^2 is not a whole number.
Show answer

Answer: A. 1.9<3.841.9 < 3.84, so fail to reject the null hypothesis.

Why the others are wrong:

  • B: A chi-square test never proves a hypothesis.
  • C: The difference is not significant, because 1.9 is below 3.84.
  • D: χ2\chi^2 is rarely a whole number.
  1. Exam-style In a hypothetical test cross, AaBb × aabb is predicted to give four phenotypes in a 1:1:1:1 ratio. The 400 offspring are:
PhenotypeNumber of offspring
Dominant for both traits160
Recessive for both traits150
Dominant for A only45
Dominant for B only45

(a) Calculate χ2\chi^2 to one decimal place.

(b) Decide at p = 0.05. Answer reject or fail to reject.

Show answer

Answer: (a) χ2=121.5\chi^2 = 121.5; (b) reject the null hypothesis.

Marking points:

  • Expected: 100 in each class.
  • 602100+502100+552100+552100=36+25+30.25+30.25=121.5\dfrac{60^2}{100} + \dfrac{50^2}{100} + \dfrac{55^2}{100} + \dfrac{55^2}{100} = 36 + 25 + 30.25 + 30.25 = 121.5.
  • df = 3, critical value 7.81; 121.5>7.81121.5 > 7.81.
  • Two classes are far more common than the other two, which suggests the genes are linked rather than assorting independently.

Key points

Recall, then reveal

Say the main points from memory first, then check them.

Show key pointsHide key points
  • The null hypothesis says observed and expected counts differ only by chance.
  • Expected counts are the predicted fraction of the total, never the ratio numbers or percentages.
  • χ2=∑(o−e)2/e\chi^2 = \sum (o - e)^2 / e; df is the number of categories minus one.
  • If χ2\chi^2 exceeds the critical value (3.84 for df = 1 at p = 0.05), reject the null hypothesis; otherwise fail to reject it.
  • Failing to reject means "consistent with the prediction", never "proved".

Keep learning

Explore AP Biology tutoring →

View the full Biology syllabus →

More in this unit

Heredity

All Mendelian Genetics notes

Part of Novark's AP Biology notes