Allele frequency chi-square test
Test whether your observed AA, Aa, aa counts match Hardy-Weinberg expectations for a given allele frequency p. Returns the per-cell contributions, total χ², and the verdict at α = 0.05 and α = 0.01.
- E(AA) = N · p²
- E(Aa) = N · 2pq
- E(aa) = N · q², with q = 1 − p
Inputs
Goodness-of-fit test versus Hardy-Weinberg expectation. df = 3 − 1 − 1 = 1 (one parameter estimated).
Worked example
A sample of 100 wallabies has 30 AA, 55 Aa, 15 aa. The expected dominant allele frequency from prior work is p = 0.6, so q = 0.4.
Expected counts:
- E(AA) = 100 · 0.36 = 36
- E(Aa) = 100 · 2 · 0.6 · 0.4 = 48
- E(aa) = 100 · 0.16 = 16
Cell contributions:
- AA: (30 − 36)² / 36 = 1.000
- Aa: (55 − 48)² / 48 = 1.021
- aa: (15 − 16)² / 16 = 0.063
χ² = 2.084, df = 1. Since 2.084 < 3.841 we fail to reject H₀ at α = 0.05: the sample is consistent with Hardy-Weinberg.
How this calculator works
The calculator takes your three observed counts and an expected dominant-allele frequency p. It builds the Hardy-Weinberg expected counts E = N·(p², 2pq, q²), sums (O − E)²/E across the three classes, and compares the total to the χ² critical values at df = 1.
Common questions
- What does this test answer?
- It tests whether the observed genotype counts in a sample match the Hardy-Weinberg expectation for a given allele frequency. A large χ² with a small p-value means the population is not in Hardy-Weinberg equilibrium.
- Why is df = 1 for three genotype classes?
- Degrees of freedom = (number of classes − 1) − (number of parameters estimated from the data). Three classes minus 1 minus 1 estimated parameter (the allele frequency p) gives df = 1.
- What is the rejection rule?
- If χ² exceeds the critical value at the chosen α level, reject H₀. For df = 1: χ²crit = 3.841 at α = 0.05 and 6.635 at α = 0.01.
- Can I use this for any goodness-of-fit?
- The maths is the same for any expected vs observed comparison, but this tool hardcodes the three Hardy-Weinberg categories. For a 9:3:3:1 dihybrid ratio you'd use a different df and different expected proportions.