Hardy-Weinberg Equilibrium Calculator
Start from p, from how common a recessive trait is, or from real genotype counts. We’ll find every frequency and test whether the population is evolving.
What do you know about the population?
p is the frequency of the dominant allele A and q = 1 − p is the frequency of a. The equation assumes random mating, no selection, no mutation, no migration, and a very large population.
Follow the calculation
What the Hardy-Weinberg equation says
For a gene with two alleles, call the frequency of the dominant allele p and the frequency of the recessive allele q. Every allele in the gene pool is one or the other, so p + q = 1. If gametes pair at random, the chance that a zygote receives two A alleles is p × p, the chance of two a alleles is q × q, and the chance of one of each is 2pq (A from the egg and a from the sperm, or the reverse). That gives the genotype frequencies p² + 2pq + q² = 1, and, in the absence of evolutionary forces, both allele and genotype frequencies stay the same from one generation to the next. Hardy-Weinberg equilibrium is the null model of evolution: the population that is not changing.
The five conditions
A population stays in equilibrium only while all of these hold: (1) a very large population, so allele frequencies do not drift by chance; (2) random mating with respect to the gene; (3) no mutation creating or destroying alleles; (4) no migration bringing alleles in or out; (5) no natural selection, so every genotype survives and reproduces equally well. Real populations violate at least one, which is exactly why the equation is useful. Measure the genotypes, compare them with p², 2pq, and q², and any significant gap points to a force worth investigating.
Worked example: how many carriers?
Cystic fibrosis is recessive and affects about 1 in 2,500 newborns of European ancestry. Only aa individuals are affected, so q² = 1/2,500 = 0.0004 and q = √0.0004 = 0.02. Then p = 1 − 0.02 = 0.98, and the carrier frequency is 2pq = 2 × 0.98 × 0.02 = 0.0392, roughly 1 person in 25. Notice the asymmetry: the disease is rare, but carriers are nearly a hundred times more common than affected people, because a recessive allele hides in heterozygotes. This is why recessive alleles are almost impossible to eliminate by selection against the affected phenotype alone.
Allele frequency versus genotype frequency
| p (A) | q (a) | p² (AA) | 2pq (Aa) | q² (aa) |
|---|---|---|---|---|
| 0.9 | 0.1 | 0.81 | 0.18 | 0.01 |
| 0.7 | 0.3 | 0.49 | 0.42 | 0.09 |
| 0.5 | 0.5 | 0.25 | 0.50 | 0.25 |
| 0.3 | 0.7 | 0.09 | 0.42 | 0.49 |
| 0.1 | 0.9 | 0.01 | 0.18 | 0.81 |
Heterozygotes are most common when p = q = 0.5, where 2pq reaches its maximum of 0.50. As either allele becomes rare, almost every copy of it sits inside a heterozygote: at q = 0.1, only 1% of the population is aa but 18% carries the allele.
Reading the chi-square verdict
In “observed counts” mode the calculator estimates p directly from the sample by counting alleles: each AA individual contributes two A alleles and each Aa contributes one, so p = (2 × AA + Aa) / 2n. It then predicts the counts expected under equilibrium (p²n, 2pqn, q²n) and computes χ² = Σ (O − E)² / E. There are three genotype classes, but one degree of freedom is lost to the total and another to estimating p from the same data, so df = 1 and the α = 0.05 critical value is 3.841. A χ² above 3.841 means the observed genotypes would arise by chance less than 5% of the time if the population were in equilibrium. A heterozygote deficit often signals inbreeding or population structure; a heterozygote excess can point to heterozygote advantage, as with the sickle-cell allele in malaria regions.
Hardy-Weinberg questions
Wondering about the why? Start here.
What is the Hardy-Weinberg equation?
For a gene with two alleles, p + q = 1 describes allele frequencies and p² + 2pq + q² = 1 describes genotype frequencies: p² homozygous dominant, 2pq heterozygous, q² homozygous recessive. If p = 0.7, then q = 0.3, and the population is expected to be 49% AA, 42% Aa, and 9% aa. The calculator expands the equation with your numbers and checks that the three terms add to 1.
Read: the Hardy-Weinberg principleHow do you find allele frequency from the recessive phenotype?
Only aa individuals show a recessive trait, so the frequency of the phenotype equals q². Take the square root to get q, then p = 1 − q. Cystic fibrosis affects about 1 in 2,500 newborns, so q² = 0.0004, q = 0.02, p = 0.98, and the carrier frequency 2pq = 0.0392, about 1 person in 26. Choose the q² tab and enter the phenotype frequency as a fraction.
Try a Hardy-Weinberg practice roundHow do you know if a population is in Hardy-Weinberg equilibrium?
Count the genotypes, estimate p from the alleles (p = (2AA + Aa) / 2n), and compare the observed counts with the counts p²n, 2pqn, and q²n predicted by the equation using a chi-square test with 1 degree of freedom. If χ² is 3.841 or less at α = 0.05, the population is consistent with equilibrium; if it is larger, something is acting on the gene: selection, non-random mating, migration, mutation, or drift in a small population. Real populations rarely meet all five conditions exactly, which is why the test is useful.
See what breaks the equilibrium