explainer
Hardy–Weinberg Equilibrium: Allele Frequencies, p²+2pq+q², and the χ² Test
By the LazyTools team · Published 2026-07-10 · Updated 2026-07-10 · 3 min read
Hardy–Weinberg says that in a population that isn’t evolving, genotype frequencies follow
p² + 2pq + q² = 1 from the allele frequencies p and q. Get p and q from the genotype counts
(p = (2·AA + Aa) / 2N), work out the expected counts, and a chi-square test tells you whether the
population is at equilibrium. Do all of it — allele frequencies, expected counts and the χ² verdict —
with the Hardy–Weinberg calculator; here’s the reasoning.
The idea in one picture
Step 1 — allele frequencies from genotype counts
Count the three genotypes and turn them into allele frequencies. Each homozygote carries two copies of its allele, each heterozygote one of each:
p = (2·AA + Aa) / (2N) and q = 1 − p
where N is the total number of individuals. For a classic textbook sample of 298 AA, 489 Aa and 213 aa (N = 1000): p = (2×298 + 489) / 2000 = 1085 / 2000 = 0.5425, so q = 0.4575.
Step 2 — expected genotype frequencies
If the population is at equilibrium, the genotype frequencies come straight from p and q:
- p² — homozygous dominant (AA)
- 2pq — heterozygous (Aa)
- q² — homozygous recessive (aa)
These sum to 1 because (p + q)² = p² + 2pq + q² = 1. Multiply each by N to get expected counts. For our example: p²·N ≈ 294, 2pq·N ≈ 496, q²·N ≈ 209.
Step 3 — test with chi-square
Now compare what you observed to what’s expected under Hardy–Weinberg with a chi-square goodness-of-fit test:
χ² = Σ (observed − expected)² / expected
with 1 degree of freedom (three genotype classes, minus one for the total, minus one for the estimated allele frequency). Our example gives a small χ² (≈ 0.22) and a p-value around 0.6 — well above 0.05 — so the population is consistent with Hardy–Weinberg equilibrium. A p-value at or below 0.05 would signal a significant departure. The Hardy–Weinberg calculator runs this test and gives the plain-English verdict.
What a departure means
Hardy–Weinberg is a null model: it describes a population where nothing is changing the allele frequencies. So when observed genotypes depart significantly from the expectation, it means one of the model’s assumptions is being violated:
- Natural selection — some genotypes survive or reproduce better.
- Non-random mating — for example inbreeding, which raises homozygotes.
- Migration (gene flow) — alleles entering or leaving the population.
- Mutation — new alleles appearing.
- Genetic drift — random change in a small population.
The test doesn’t tell you which — it tells you that the simple no-evolution model doesn’t fit, which is the starting point for asking why.
Quick summary
Hardy–Weinberg predicts genotype frequencies from allele frequencies: p + q = 1 and p² + 2pq + q² = 1. Get p and q from counts with p = (2·AA + Aa)/2N, compute expected counts, and test observed-versus-expected with a chi-square goodness-of-fit at 1 degree of freedom — p > 0.05 means the population is consistent with equilibrium. Run the frequencies, expected counts and the χ² verdict with the Hardy–Weinberg calculator, and see where a single cross comes from with the Punnett square calculator.
Sources: Hardy (1908) and Weinberg (1908), the Hardy–Weinberg principle; standard population-genetics texts. NHGRI — genetics glossary. Educational information.
Frequently asked questions
What is the Hardy–Weinberg equation?
p² + 2pq + q² = 1, where p and q are the frequencies of two alleles (p + q = 1). p² is the expected frequency of homozygous dominant individuals, 2pq of heterozygotes, and q² of homozygous recessive. It predicts genotype frequencies in a population that is not evolving.
How do you calculate allele frequency from genotype counts?
p = (2 × AA + Aa) / (2 × N) and q = 1 − p, where AA, Aa and aa are the counts of each genotype and N is the total number of individuals. Each homozygote contributes two copies of its allele and each heterozygote one of each.
How do you test for Hardy–Weinberg equilibrium?
Compare the observed genotype counts to those expected from p², 2pq and q² using a chi-square goodness-of-fit test with 1 degree of freedom. If the p-value is above 0.05 the population is consistent with equilibrium; if it is 0.05 or below, there is a significant departure.
Why is there 1 degree of freedom?
There are three genotype classes, minus one for the fixed total, minus one for the allele frequency estimated from the data, leaving 3 − 1 − 1 = 1 degree of freedom for a locus with two alleles.
What causes a departure from Hardy–Weinberg equilibrium?
A significant departure means one of the model's assumptions is broken: natural selection, non-random mating (such as inbreeding), migration (gene flow), mutation, or genetic drift in a small population. The test flags that something is acting; it doesn't say which.
What are the assumptions of Hardy–Weinberg?
No selection, no mutation, no migration, an infinitely large population (no drift), and random mating. When all hold, allele and genotype frequencies stay constant across generations — the equilibrium state.