Hardy-Weinberg Equation Calculator
Solve the Hardy-Weinberg equation from whatever a problem gives you, the recessive phenotype, the carriers, the dominant phenotype or one allele's frequency, autosomal or X-linked, with every step of the working. Or enter genotype counts to estimate p and q by counting alleles and test whether the population is in equilibrium, by chi-square or the exact test.
Calculator
Solve Hardy-Weinberg
The share showing the recessive trait or condition, aa.
As 0.04, 4%, 1 in 2,500 or 16 of 400.
To see how many individuals each share is.
Allele names (optional)
Use your problem's letters, and the lists, the working and the copied answer use them: M and N for the MN blood group, or HbA and HbS.
Allele frequencies
- p · A
- 0.6
- q · a
- 0.4
A has a frequency of 0.6 and a of 0.4, so 36% of individuals are AA, 48% Aa and 16% aa.
Genotype frequencies
Tap one to find it in the square
Working
- 01q² = 0.16
- 02q = √q² = √0.16 = 0.4
- 03p = 1 − q = 1 − 0.4 = 0.6
- 04p² = 0.6² = 0.36
- 052pq = 2 × 0.6 × 0.4 = 0.48
Genotype frequency against q
Worked example
Cystic fibrosis: 1 baby in 2,500, so how many carriers?
- 01Cystic fibrosis is recessive, so affected babies are aa: q² = 1 ÷ 2,500 = 0.0004
- 02q = √0.0004 = 0.02, the frequency of the cystic fibrosis allele
- 03p = 1 − q = 1 − 0.02 = 0.98
- 04Carriers: 2pq = 2 × 0.98 × 0.02 = 0.0392; non-carriers: p² = 0.98² = 0.9604
3.92% of people, 1 in 25.5 (the 1 in 25 usually quoted), carry one copy of the allele: 98 carriers for every baby born with cystic fibrosis.
How it works
How to solve Hardy-Weinberg problems
The Hardy-Weinberg principle says that in a large population that mates at random, allele frequencies stay the same from one generation to the next, and genotypes settle within one generation into the proportions p², 2pq and q². Picture the gene pool as a Punnett square: each egg carries A with chance p and a with chance q, and so does each sperm, so a child is AA with chance p × p, aa with q × q, and Aa with pq + qp, which is 2pq.
Most problems give you one number. When it is the share with a recessive trait or condition, that is q²: take its square root for q, then p = 1 − q, then 2pq for the carriers. When it is the share with the dominant phenotype, subtract it from 1 to get q² first. When it is the carriers, 2q(1 − q) = 2pq has two answers, q and 1 − q, and the rarer allele is usually the one meant.
To test real counts, find p by counting alleles: each AA carries two copies of A and each Aa one, out of 2n. Multiply p², 2pq and q² by n for the expected counts and compare them with the observed by chi-square, with 1 degree of freedom: a χ² above 3.841, a P below 0.05, means the counts are not in Hardy-Weinberg proportions. With a small sample or a rare allele, the exact test gives a P that chi-square cannot; genome studies run it on every marker as a check on the genotyping.
The equilibrium holds only while five conditions do: no mutation, no migration (gene flow), no natural selection, random mating, and a population large enough that chance (genetic drift) does little. Too few heterozygotes points to inbreeding, or to a sample that mixes separate groups (the Wahlund effect); too many, to selection for heterozygotes, as with sickle-cell haemoglobin where malaria is common.
Questions
Frequently asked
What is the Hardy-Weinberg equation?
p² + 2pq + q² = 1, together with p + q = 1. Here p and q are the frequencies of the two alleles of a gene, and p², 2pq and q² are the frequencies of the genotypes AA, Aa and aa in a population in Hardy-Weinberg equilibrium. With q = 0.4, for example, 36% are AA, 48% Aa and 16% aa.
How do you calculate allele frequency?
From genotype counts, count the alleles: p = (2 × AA + Aa) ÷ 2n, where n is the number of individuals, and q = 1 − p. A sample of 36 AA, 48 Aa and 16 aa has p = (72 + 48) ÷ 200 = 0.6. When only phenotypes are known and a is recessive, q is the square root of the share showing the recessive trait.
How do you find the carrier frequency with Hardy-Weinberg?
Take the square root of the share with the recessive condition for q, then the carriers are 2pq. For cystic fibrosis, about 1 baby in 2,500 is affected, so q = √0.0004 = 0.02 and 2pq = 2 × 0.98 × 0.02 = 0.0392, about 1 person in 25. When q is small, 2pq is close to 2q.
What are the five conditions of Hardy-Weinberg equilibrium?
No mutation, no migration into or out of the population (gene flow), no natural selection, random mating, and a very large population, so that chance changes in allele frequency (genetic drift) are negligible. While all five hold, allele and genotype frequencies stay the same from one generation to the next.
How many degrees of freedom does a Hardy-Weinberg chi-square test have?
One, for a gene with two alleles. Three genotype classes would give 2, but one more is lost because the allele frequency behind the expected counts was estimated from the same data. So the critical value at the 0.05 level is 3.841, not 5.991.
Does Hardy-Weinberg work for X-linked traits?
Yes, with one change: men have one X, so the share of men with a recessive X-linked trait is q itself, while women with it are q² and women who carry it 2pq. If 8% of men are red-green colour blind, q = 0.08, so 0.64% of women are expected to be colour blind and 14.72% to be carriers.
More Calculators
Each one shows its formula and a worked example, so you can check the answer and learn the method.
Chi-Square Calculator
Test a table of counts for an association, or counts against a ratio such as 3:1 or 9:3:3:1, with the expected counts, P value and working.
Open calculatorDihybrid Cross Calculator
The Punnett square for any cross of two genes, with the gametes, the genotype and phenotype ratios, gene interactions and a chi-square test of your counts.
Open calculatorSample Size and Power Calculator
How many participants a survey or a two-group study needs, or the power of the sample you have, with a paragraph for your methods.
Open calculatorPractice the theory with free quizzes in Genetics, Evolution, Genomics and Bioinformatics.