The Hardy-Weinberg principle is population genetics’ null hypothesis: if nothing is acting on a population — no selection, no migration, no drift — allele frequencies stay put and genotype frequencies settle into a simple pattern you can compute from a single number. This Hardy-Weinberg equilibrium calculator works both directions: turn an allele frequency into expected genotype frequencies, or feed it observed genotype counts and get the allele frequencies, the expected counts, and a chi-square test of whether your population is actually in equilibrium.
The Hardy-Weinberg Equations
For a gene with two alleles, A and a, let p be the frequency of A and q the frequency of a. Every allele in the population is one or the other, so p + q = 1. Random mating is like drawing two alleles independently from the pool, so genotype frequencies follow the square of that sum: p² + 2pq + q² = 1, where p² is the AA frequency, 2pq is the Aa frequency, and q² is the aa frequency. That is the whole engine of this calculator: one allele frequency determines everything, and comparing the predicted genotype counts with real counts tests whether evolution's forces are detectably at work.
Worked Example 1: From Allele Frequency to Genotypes
Suppose the recessive allele has frequency q = 0.3. Then p = 1 − 0.3 = 0.7, and the genotype frequencies are AA = 0.49, Aa = 2 × 0.7 × 0.3 = 0.42, aa = 0.09. In a population of 1,000 individuals in equilibrium you would expect about 490 AA, 420 Aa, and 90 aa. Note the classic lesson hiding in the numbers: the recessive phenotype shows in only 9 percent of individuals, but 42 percent are carriers — recessive alleles mostly hide in heterozygotes.
Worked Example 2: Testing a Real Population
You genotype 1,000 individuals and count 490 AA, 420 Aa, 90 aa. First recover the allele frequencies from the counts: each AA contributes two A alleles and each Aa one, so p = (2 × 490 + 420) ÷ 2,000 = 0.7 and q = 0.3. The expected counts are then 490, 420, and 90 — identical to the observed — so chi-square = 0.000 and the population sits exactly in equilibrium. Real data is never this tidy, which is the point of the test: the calculator's chi-square compares observed and expected counts, and values above 3.841 (the 5 percent critical value with one degree of freedom) flag a significant deviation worth investigating.
The Five Conditions — and What Breaks Them
Equilibrium requires: no mutation (alleles are not being created or converted), no migration (no gene flow in or out), no selection (all genotypes survive and reproduce equally), random mating (no mate choice based on this gene), and a very large population (so chance drift is negligible). Every real population violates these a little; the chi-square test tells you whether the violation is big enough to measure. A deficit of heterozygotes suggests inbreeding or population subdivision; an excess can signal balancing selection or genotyping problems.
Why Carriers Matter: Recessive Disease Arithmetic
The most practical use of Hardy-Weinberg is medical. If a recessive condition affects 1 in 10,000 births, then q² = 0.0001, so q = 0.01 and the carrier frequency 2pq is about 0.0198 — roughly 1 person in 50 carries the allele, two hundred times the affected rate. Genetic counselors run exactly this calculation, backwards from disease incidence to carrier risk, and it is why screening programs target carrier frequencies rather than case counts.
Common Mistakes
The most common error is confusing allele frequency with genotype frequency — reading "9 percent show the trait" as q = 0.09 instead of q² = 0.09 (so q = 0.3). Second is forgetting the factor of 2 in 2pq: heterozygotes can form two ways (A from mother or from father). Third is testing equilibrium with tiny samples, where chi-square is unreliable — expected counts below about 5 per class make the test shaky. Finally, a significant result does not name its cause; it opens an investigation, it does not close one.
Related Tools
Continue in the Biology Calculators hub with the companion Allele Frequency Calculator and the Generation Time Calculator for growth dynamics.
Frequently Asked Questions
What does the Hardy-Weinberg equation state?
For two alleles with frequencies p and q: p + q = 1, and genotype frequencies are p² (AA), 2pq (Aa), and q² (aa), summing to 1. Given any one allele frequency, the full genotype distribution follows.
How do I find p and q from genotype counts?
Count alleles. p = (2 × AA count + Aa count) ÷ (2 × total individuals); q = 1 − p. Each homozygote carries two copies of its allele; each heterozygote carries one of each.
What does the chi-square value tell me?
It measures how far observed genotype counts sit from Hardy-Weinberg expectations. With one degree of freedom, chi-square above 3.841 is significant at the 5 percent level — evidence the population is not in equilibrium.
Why is the heterozygote term 2pq and not pq?
A heterozygote can be formed two ways — A egg with a sperm, or a egg with A sperm. Each way has probability pq, so the total is 2pq.
How common are carriers of a rare recessive trait?
Far more common than affected individuals. If q² = 1 in 10,000 (q = 0.01), carriers 2pq ≈ 1 in 50 — the calculation this page's second worked example demonstrates.
What forces push a population out of equilibrium?
Selection, mutation, migration (gene flow), genetic drift in small populations, and non-random mating such as inbreeding or assortative mating. The Hardy-Weinberg conditions list them exactly.
Does Hardy-Weinberg apply to genes with more than two alleles?
Yes — the principle generalizes to (p + q + r + …)². This calculator covers the classic two-allele case, which handles the great majority of textbook and field applications.