How to Do a Chi Square Test for AP Biology

What You Need to Know

What it is (and why AP Bio loves it)

A chi-square test (usually a goodness-of-fit test in AP Biology) checks whether your observed results are close enough to your expected results that any difference could reasonably be due to random chance.

You’ll use it most often for:

  • Mendelian genetics crosses (do offspring counts fit a 3:13:1, 9:3:3:19:3:3:1, 1:2:11:2:1, etc.?)
  • Hardy–Weinberg genotype frequencies (do observed genotypes match expected p2:2pq:q2p^2 : 2pq : q^2?)
  • Any categorical data where you have predicted proportions.

Key idea: Chi-square doesn’t “prove” your expected ratio is correct. It tests whether the deviation from expectation is small enough to be explained by chance.

The core formula

You compute the test statistic:

χ2=(OE)2E\chi^2 = \sum \frac{(O - E)^2}{E}

  • OO = observed count in a category
  • EE = expected count in that category
  • Sum across all categories
Hypotheses (what you’re actually claiming)
  • Null hypothesis H0H_0: Any difference between observed and expected is due to chance (the model fits).
  • Alternative hypothesis HAH_A: The difference is not due to chance (the model does not fit).
Decision rule (AP Bio style)

You compare your χ2\chi^2 value to a critical value from a chi-square table using:

  • degrees of freedom dfdf
  • a significance level, usually α=0.05\alpha = 0.05

If χ2\chi^2 is **greater than or equal to** the critical value, you **reject** H0H_0.
If χ2\chi^2 is **less than** the critical value, you **fail to reject** H0H_0.

“Fail to reject” is the correct wording (not “accept”).


Step-by-Step Breakdown

The full workflow (what to do on an FRQ)
  1. State the hypotheses clearly.

    • H0H_0: Observed counts match the expected ratio; deviations are due to chance.
    • HAH_A: Observed counts do not match the expected ratio; deviations are not due to chance.
  2. Write the expected ratio or expected probabilities.
    Examples: 3:13:1, 9:3:3:19:3:3:1, p2:2pq:q2p^2:2pq:q^2, etc.

  3. Compute expected counts for each category.

    • Find total NN.
    • Convert ratio to proportions and multiply by NN.

    If ratio is a:b:c:...a:b:c:... with sum SS, then for each category:
    Ei=ratio partiSNE_i = \frac{\text{ratio part}_i}{S} \cdot N

  4. Make a quick table and calculate each term.
    Use columns: category | OO | EE | OEO-E | (OE)2(O-E)^2 | (OE)2E\frac{(O-E)^2}{E}.

  5. Sum to get χ2\chi^2.
    χ2=(OE)2E\chi^2 = \sum \frac{(O-E)^2}{E}

  6. Find degrees of freedom.
    For goodness-of-fit:
    df=k1df = k - 1
    where kk = number of categories (phenotypes or genotypes you’re counting).

  7. Choose α\alpha (usually 0.050.05) and get the critical value.
    Use the chi-square table at α=0.05\alpha = 0.05 and your dfdf.

  8. Compare and conclude in words (biological meaning).

    • If χ2χcritical2\chi^2 \ge \chi^2_{critical}: reject H0H_0 → results do not fit expectation; something besides chance likely affected outcomes.
    • If χ2<χcritical2\chi^2 < \chi^2_{critical}: fail to reject H0H_0 → results fit expectation; deviations likely due to chance.
Mini worked walkthrough (annotated)

Suppose a monohybrid cross expects 3:13:1 purple:white. You observe O=65O = 65 purple and O=35O = 35 white.

  • Total N=100N = 100
  • Expected counts: purple E=34100=75E = \frac{3}{4} \cdot 100 = 75; white E=14100=25E = \frac{1}{4} \cdot 100 = 25

Compute:

  • Purple term: (6575)275=10075=1.33\frac{(65-75)^2}{75} = \frac{100}{75} = 1.33
  • White term: (3525)225=10025=4.00\frac{(35-25)^2}{25} = \frac{100}{25} = 4.00

So:
χ2=1.33+4.00=5.33\chi^2 = 1.33 + 4.00 = 5.33

Degrees of freedom: df=21=1df = 2-1 = 1.
Critical value at α=0.05\alpha = 0.05, df=1df = 1 is 3.843.84.

Since 5.33>3.845.33 > 3.84, **reject** H0H_0.


Key Formulas, Rules & Facts

Formulas and definitions
ItemFormulaWhen to useNotes
Chi-square statisticχ2=(OE)2E\chi^2 = \sum \frac{(O-E)^2}{E}Goodness-of-fit for categorical countsBigger χ2\chi^2 = bigger mismatch
Expected count from ratioEi=ratio partipartsNE_i = \frac{\text{ratio part}_i}{\sum \text{parts}} \cdot NMendelian ratios (e.g., 9:3:3:19:3:3:1)Compute EE before chi-square
Degrees of freedomdf=k1df = k - 1Chi-square goodness-of-fitkk = number of categories
Decision ruleCompare χ2\chi^2 to critical value at dfdf and α\alphaMost AP Bio problemsIf χ2χcritical2\chi^2 \ge \chi^2_{critical} → reject H0H_0
Common critical values (most used on AP Bio)

(These are for α=0.05\alpha = 0.05.)

dfdfχcritical2\chi^2_{critical}
113.843.84
225.995.99
337.817.81
449.499.49
5511.0711.07
6612.5912.59
7714.0714.07

If your table gives ranges or multiple α\alpha values, AP Bio typically expects α=0.05\alpha = 0.05 unless stated otherwise.

Assumptions / conditions you should check
  • Counts, not percentages (convert to counts if needed).
  • Categories are mutually exclusive (each observation fits one category).
  • Observations are independent (one offspring doesn’t determine another).
  • Expected counts should not be too small; a common rule is each E5E \ge 5 (AP-level expectation: “expected values should be sufficiently large”).

Examples & Applications

Example 1: Monohybrid cross (fits expectation)

A cross predicts 3:13:1 phenotype ratio. Observed: purple 547547, white 193193.

  • Total N=740N = 740
  • Expected: purple E=34740=555E = \frac{3}{4}\cdot 740 = 555; white E=14740=185E = \frac{1}{4}\cdot 740 = 185

Compute terms:

  • Purple: (547555)2555=645550.115\frac{(547-555)^2}{555} = \frac{64}{555} \approx 0.115
  • White: (193185)2185=641850.346\frac{(193-185)^2}{185} = \frac{64}{185} \approx 0.346

χ20.461\chi^2 \approx 0.461

df=21=1df = 2-1 = 1, critical =3.84= 3.84.
Since 0.461<3.840.461 < 3.84, **fail to reject** H0H_0 → data are consistent with 3:13:1.

Example 2: Dihybrid cross (fits expectation)

Expected ratio 9:3:3:19:3:3:1 for 4 phenotypes; total N=160N = 160.
Observed counts: 90,30,28,1290, 30, 28, 12.

Expected counts:

  • 9/16160=909/16\cdot160 = 90
  • 3/16160=303/16\cdot160 = 30
  • 3/16160=303/16\cdot160 = 30
  • 1/16160=101/16\cdot160 = 10

Compute only nonzero differences:

  • Third category: (2830)230=4300.133\frac{(28-30)^2}{30} = \frac{4}{30} \approx 0.133
  • Fourth category: (1210)210=410=0.4\frac{(12-10)^2}{10} = \frac{4}{10} = 0.4

χ20.533\chi^2 \approx 0.533

df=41=3df = 4-1 = 3, critical =7.81= 7.81.
Since 0.533<7.810.533 < 7.81, **fail to reject** H0H_0.

Example 3: Monohybrid cross (reject expectation)

Observed: 6565 dominant phenotype, 3535 recessive phenotype; expected 3:13:1.

  • N=100N = 100
  • Expected: 7575 and 2525
  • χ2=(6575)275+(3525)225=1.33+4.00=5.33\chi^2 = \frac{(65-75)^2}{75} + \frac{(35-25)^2}{25} = 1.33 + 4.00 = 5.33
  • df=1df = 1; critical 3.843.84

Since 5.33>3.845.33 > 3.84, **reject** H0H_0 → likely not a 3:13:1 outcome (or some non-random factor impacted results).

Example 4: Hardy–Weinberg genotype fit

A population has allele frequencies p=0.6p = 0.6 and q=0.4q = 0.4. Total individuals N=200N = 200.
Expected genotypes:

  • p2=0.36p^2 = 0.36E(AA)=0.36200=72E(AA) = 0.36\cdot200 = 72
  • 2pq=0.482pq = 0.48E(Aa)=96E(Aa) = 96
  • q2=0.16q^2 = 0.16E(aa)=32E(aa) = 32

Observed genotypes: AA=80AA = 80, Aa=70Aa = 70, aa=50aa = 50.

Compute:

  • (8072)272=64720.889\frac{(80-72)^2}{72} = \frac{64}{72} \approx 0.889
  • (7096)296=676967.042\frac{(70-96)^2}{96} = \frac{676}{96} \approx 7.042
  • (5032)232=32432=10.125\frac{(50-32)^2}{32} = \frac{324}{32} = 10.125

χ218.056\chi^2 \approx 18.056

df=31=2df = 3-1 = 2; critical at df=2df=2 is 5.995.99.
Since 18.056>5.9918.056 > 5.99, **reject** H0H_0 → observed genotype frequencies significantly deviate from HW expectations.


Common Mistakes & Traps

  1. Mixing up observed and expected

    • Wrong: Plugging observed values into the expected column or vice versa.
    • Why it matters: The whole statistic is based on differences OEO-E.
    • Fix: Always compute EE from the _ratio/probability_ first, then compare to OO.
  2. Using the ratio numbers as expected counts without scaling

    • Wrong: Treating 9:3:3:19:3:3:1 as expected counts 9,3,3,19,3,3,1 even when N16N \ne 16.
    • Fix: Convert ratio to fractions of the total and multiply by NN.
  3. Forgetting to square the difference (or squaring after dividing)

    • Wrong: Using OEE\frac{O-E}{E} or doing (OEE)2\left(\frac{O-E}{E}\right)^2.
    • Correct: (OE)2E\frac{(O-E)^2}{E} (square first, then divide).
  4. Incorrect degrees of freedom

    • Wrong: Using df=N1df = N-1 (sample size) or df = \text{#traits}-1.
    • Correct: df=k1df = k-1 where kk is the number of categories you actually have counts for.
  5. Saying “accept the null”

    • Wrong: “We accept H0H_0.”
    • Why it’s wrong: Statistics doesn’t prove H0H_0; it only assesses evidence against it.
    • Fix: Say fail to reject H0H_0.
  6. Using the wrong chi-square table column (wrong α\alpha)

    • Wrong: Comparing to a 0.010.01 column when the problem expects 0.050.05.
    • Fix: Default to α=0.05\alpha = 0.05 unless the prompt specifies otherwise.
  7. Rounding too aggressively mid-calculation

    • Wrong: Rounding each term heavily (e.g., to whole numbers).
    • Fix: Keep a few decimals for each term; round at the end.
  8. Ignoring small expected counts

    • Issue: If some EE values are very small, the chi-square approximation becomes less reliable.
    • Fix (AP-level): Note it as a limitation, or (if allowed) combine rare categories logically.

Memory Aids & Quick Tricks

Trick / mnemonicWhat it helps you rememberWhen to use it
“O–E, square, over E, then sum”The exact structure of (OE)2E\frac{(O-E)^2}{E}Any chi-square computation
“df = boxes − 1”df=k1df = k-1 where kk = number of categoriesChoosing the right row in the table
“Big chi = bye null”Large χ2\chi^2 means poor fit → reject H0H_0Interpreting results quickly
Ratio → fractions → countsConvert expected ratios to expected counts correctlyGenetics crosses with a ratio
Table-first habitPrevents arithmetic/sign errors by organizing termsFRQs and multi-category problems

Quick Review Checklist

  • You can state H0H_0 (chance explains differences) and HAH_A (chance doesn’t).
  • You can compute expected counts using Ei=partsumNE_i = \frac{\text{part}}{\text{sum}}\cdot N.
  • You can calculate χ2=(OE)2E\chi^2 = \sum \frac{(O-E)^2}{E} correctly (square first).
  • You can find df=k1df = k-1 using the number of categories.
  • You can use α=0.05\alpha = 0.05 and compare to the correct critical value.
  • You conclude using: reject H0H_0 or **fail to reject** H0H_0 (in context).
  • You check that expected counts are reasonably large (ideally E5E \ge 5).

You’ve got this—if you can set up the O/EO/E table cleanly, the rest is just careful arithmetic.