About the Hardy-Weinberg Calculator
This Hardy-Weinberg calculator works out allele frequencies (p and q) and the expected genotype frequencies (p², 2pq and q²) for a gene with two alleles. You can start from observed genotype counts, from the percentage of the population showing the recessive trait, or directly from an allele frequency.
With genotype counts it also runs the standard chi-square goodness-of-fit test (1 degree of freedom) to check whether the population departs from Hardy-Weinberg equilibrium — the classic exercise in biology and genetics courses. From a recessive phenotype frequency it estimates the carrier (heterozygote) rate, which is how the commonly quoted carrier frequencies for recessive conditions are derived.
Hardy-Weinberg predictions assume a large, randomly mating population with no selection, mutation, migration or genetic drift, and an autosomal gene with two alleles. Real populations rarely meet every assumption, so treat the expected values as a null model to test against, not a guaranteed outcome.
With the default inputs, the dominant allele frequency p is 0.65. Change any value above to recalculate instantly.
How to use the hardy-weinberg calculator
- 1Choose what you know: genotype counts, the recessive phenotype share, or p.
- 2Enter the counts or frequency.
- 3For frequency modes, set a population size to see expected counts.
- 4Read p, q and the p², 2pq and q² genotype frequencies.
- 5With counts, check the chi-square p-value to see if the population is in equilibrium.
Formula and method
With genotype counts, each AA individual carries two copies of allele A and each Aa carries one, so p = (2·AA + Aa) ÷ (2N) and q = 1 − p. Under Hardy-Weinberg equilibrium the genotype frequencies are p², 2pq and q², and multiplying by N gives the expected counts. The chi-square statistic compares observed and expected counts; with three genotype classes and one estimated parameter there is 1 degree of freedom, and χ² > 3.841 means p < 0.05.
If you only know how many people show a recessive trait, that share is q², so q = √(q²) and p = 1 − q. This is how carrier rates for recessive conditions are estimated, but it relies on random mating and no selection.
- p
- Frequency of the dominant allele A
- q
- Frequency of the recessive allele a (1 − p)
- p², 2pq, q²
- Expected frequencies of AA, Aa and aa
- N
- Number of individuals sampled
- O, E
- Observed and expected genotype counts
Worked examples
Sample of 100: 50 AA, 30 Aa, 20 aa
p = (2 × 50 + 30) ÷ 200 = 0.65 and q = 0.35. Expected counts are 42.25 AA, 45.5 Aa and 12.25 aa. χ² = 7.75²/42.25 + 15.5²/45.5 + 7.75²/12.25 ≈ 11.60, above 3.841, so the sample has too few heterozygotes to be in equilibrium (p ≈ 0.0007).
16% show the recessive trait
q² = 0.16, so q = 0.4 and p = 0.6. Then p² = 36% homozygous dominant and 2pq = 48% heterozygous — almost half of the people who show the dominant trait are carriers.
Rare recessive condition, 1 in 2,500 affected
q² = 0.0004, so q = 0.02 and p = 0.98. The carrier frequency 2pq = 2 × 0.98 × 0.02 = 3.92%, or about 1 in 25.5 people, even though only 1 in 2,500 is affected.
Frequently asked questions
What is the Hardy-Weinberg equation?+
It has two parts: p + q = 1 for the two allele frequencies, and p² + 2pq + q² = 1 for the genotype frequencies AA, Aa and aa. It predicts genotype frequencies from allele frequencies in a population that is not evolving.
How do I find p and q from genotype counts?+
Count alleles: p = (2 × AA + Aa) ÷ (2 × total individuals), because homozygotes carry two copies and heterozygotes one. Then q = 1 − p, or equivalently (2 × aa + Aa) ÷ (2N).
What are the five Hardy-Weinberg assumptions?+
No mutation, random mating, no natural selection, a very large population (no genetic drift) and no gene flow from migration. Violating any of them can shift genotype frequencies away from p², 2pq and q².
How do I test whether a population is in Hardy-Weinberg equilibrium?+
Compute expected counts from p and q, then χ² = Σ(O − E)²/E across the three genotypes. With 1 degree of freedom the critical value at α = 0.05 is 3.841; a larger χ² means a significant departure from equilibrium.
Why can I not just count dominant phenotypes to get p?+
Individuals with the dominant phenotype include both AA and Aa genotypes, which look the same. Only the recessive phenotype reveals its genotype (aa), so you start from q² = recessive share and work back to q and p.