Hardy-Weinberg Equilibrium, Explained
After reading this you can turn a single allele frequency into expected genotype frequencies, work allele frequencies back out from genotype counts, and test whether a population departs from equilibrium.
Imagine a wildflower where purple petals (allele A) are dominant over white (allele a). You count 500 plants and find 320 purple homozygotes, 160 heterozygotes, and 20 white recessives. Is that pattern what random mating would produce, or is something bending it? The Hardy-Weinberg model gives you the baseline expectation. Deviations from that baseline are the interesting part.
What the model says
A population carries two alleles at one locus, A and a, with frequencies p and q. Because every allele copy is one or the other, the two frequencies must add to one.
Here p is the fraction of all allele copies that are A, and q is the fraction that are a. If p = 0.6 then q = 0.4, always.
Now suppose mating is random: any allele copy pairs with any other, like drawing two marbles from a bag. The chance of drawing A twice is p \times p. The chance of two a copies is q \times q. A heterozygote can form two ways (A then a, or a then A), so its probability is 2pq. Those three genotype frequencies sum to one.
p^2 is the expected frequency of AA, 2pq of Aa, and q^2 of aa. That single line is the whole model. The rest is arithmetic and interpretation.
When to use it, and when not to
Use Hardy-Weinberg when you have one locus with two alleles and you want a reference point: what should the genotype counts look like with no evolutionary forces acting? It is the null hypothesis of population genetics. You reach for it to estimate carrier frequency for a recessive disease, to sanity-check genotyping data, or to detect selection or non-random mating by measuring the gap between expected and observed.
The equilibrium rests on five assumptions: a large population, random mating, and no selection, mutation, or migration. Do not apply it blindly when any of these clearly fails. A tiny population drifts by chance. Strong inbreeding inflates homozygotes. A gene under heavy selection will not sit at equilibrium. In those cases the model still helps, but as a comparison, not a description.
The frequencies p and q describe alleles, not individuals. A heterozygote carries one copy of each allele. Confusing genotype proportions with allele proportions is the single most common error, and it throws off every downstream number.
Intuition for the square
The 2pq term surprises people. Why double? Think of a 2 by 2 grid of gamete combinations, the same idea behind a Punnett square. One axis is the allele from parent one, the other axis the allele from parent two. Each axis has A with probability p and a with probability q. The four cells hold probabilities p^2, pq, pq, and q^2. The two off-diagonal cells are both heterozygotes, so they combine into 2pq.
One consequence worth remembering: heterozygotes peak at p = 0.5, where 2pq = 0.5. When an allele is rare, say q = 0.01, most copies of it hide in heterozygotes. The recessive phenotype frequency is q^2 = 0.0001, but the carrier frequency 2pq = 0.0198 is about 200 times larger. This is why rare recessive alleles persist: selection rarely sees them.
Worked example: the demo data
Run the tool in counts mode with the sample data: 320 AA, 160 Aa, and 20 aa. This shows how to recover allele frequencies and then test the fit.
From genotype counts back to alleles
- Total individuals:
320 + 160 + 20 = 500. Total allele copies:500 × 2 = 1000, since each diploid individual holds two. - Count
Acopies. EachAAgives two, eachAagives one:2(320) + 160 = 800. - Allele frequency p = 800 / 1000 = 0.8. Then q = 1 - 0.8 = 0.2.
- Expected frequencies: p^2 = 0.64, 2pq = 2(0.8)(0.2) = 0.32, q^2 = 0.04.
- Expected counts in 500 plants:
0.64 × 500 = 320AA,0.32 × 500 = 160Aa,0.04 × 500 = 20aa.
The observed and expected counts match exactly (320, 160, 20). This population sits right at Hardy-Weinberg equilibrium. That is deliberate in the demo data so you can confirm the arithmetic.
Notice the shortcut hidden in step 3. The frequency of A equals the frequency of AA plus half the frequency of Aa: p = 0.64 + 0.5(0.32) = 0.8. Half of each heterozygote's alleles are A, which is why you add half the heterozygote count.
| Genotype | Observed | Frequency | Expected |
|---|---|---|---|
| AA | 320 | 0.64 | 320 |
| Aa | 160 | 0.32 | 160 |
| aa | 20 | 0.04 | 20 |
Reading and interpreting the result
When observed and expected match, as in the demo, the population is consistent with equilibrium. The more useful case is a mismatch. Suppose you instead observed 360 AA, 80 Aa, and 60 aa in 500 plants. The allele count is unchanged: 2(360) + 80 = 800, so p = 0.8 still. Expected counts are still 320, 160, 20. But observed homozygotes are inflated and heterozygotes are scarce (80 versus 160).
An excess of homozygotes with a deficit of heterozygotes is the classic signature of inbreeding or population structure. A deficit of homozygotes can signal heterozygote advantage. To decide whether a gap is real or just sampling noise, run a chi-square test: sum (O - E)^2 / E across the three genotypes and compare to a chi-square distribution with one degree of freedom (three categories minus one, minus one estimated allele frequency).
For the inflated example: (360-320)^2/320 + (80-160)^2/160 + (60-20)^2/20 = 5 + 40 + 80 = 125. The critical value at one degree of freedom and 5 percent is 3.84. Since 125 far exceeds 3.84, you reject equilibrium decisively.
Common mistakes
Three errors account for most wrong answers.
- Treating q^2 as the carrier frequency
- q^2 is the frequency of affected recessive homozygotes. Carriers are heterozygotes at frequency 2pq. For a disease with q^2 = 0.0004, so q = 0.02, carrier frequency is 2(0.98)(0.02) = 0.0392, nearly 1 in 25.
- Forgetting the factor of two on alleles
- Total allele copies are twice the number of individuals. Dividing an allele count by the number of people instead of by twice that number halves your frequency.
- Assuming equilibrium proves no evolution
- Matching Hardy-Weinberg for one generation does not mean forces are absent. It means they are too weak to detect in your sample, or they cancel out. Equilibrium is a null, not a certificate.
Related tools
Once you have genotype frequencies, a Punnett Square Calculator shows the offspring ratios from a specific cross, the microscopic mechanism behind the 2pq term. If you work upstream at the sequence level, the DNA & RNA Sequence Toolkit handles transcription, translation, and GC content. For population dynamics over time rather than genotype proportions, the Bacterial Growth Calculator models exponential change, and the Michaelis-Menten Kinetics Calculator covers enzyme reaction rates.
Frequently asked questions
How do I find allele frequency from genotype counts?
Count allele copies, not individuals. Frequency of A equals (2 × AA count + Aa count) divided by (2 × total individuals). With 320 AA, 160 Aa, and 20 aa: (640 + 160) / 1000 = 0.8.
What does it mean if observed counts differ from expected?
A statistically significant gap points to a broken assumption: selection, non-random mating, small population size, migration, or mutation. An excess of homozygotes usually means inbreeding. Test significance with a chi-square value; anything above 3.84 at one degree of freedom rejects equilibrium at the 5 percent level.
Why is the heterozygote term 2pq and not pq?
A heterozygote can form two ways: allele A from the first parent and a from the second, or the reverse. Each path has probability pq, and they add to 2pq.
Can I use this for more than two alleles?
Yes, by expanding the square. For three alleles with frequencies p, q, and r summing to one, the genotype frequencies come from (p + q + r)^2. This calculator handles the standard two-allele case.
Does a large sample guarantee equilibrium?
No. Large samples satisfy the large-population assumption and make the chi-square test more sensitive, but the population can still deviate through selection or non-random mating. A large sample makes real deviations easier to detect, not less likely to exist.