Hardy–Weinberg Equilibrium Calculator

Allele frequencies
Leave exactly one frequency blank and it is filled in so that all of them add up to 1.
Expected numbers
Adds the expected number of individuals with each genotype.
Biology Updated 29 Oct 2026

Applies the Hardy–Weinberg principle in three ways. Enter allele frequencies (two to five alleles) to get every expected genotype frequency; start from one known genotype or phenotype frequency, such as the share of people affected by a recessive disease or the share who are carriers, to recover p, q, p², 2pq and q² and the carrier rate as '1 in X'; or enter observed AA, Aa and aa counts to get allele frequencies, expected counts and a chi-square test of whether the sample is in equilibrium.

  • Random mating, no selection, mutation or migration, and a population large enough that drift can be ignored.
  • Autosomal locus in a diploid organism; X-linked genes have different expected frequencies in males.
  • When starting from a disease prevalence, every affected person is assumed to be homozygous for the same recessive allele (no new mutations, full penetrance).
  • The chi-square test uses the large-sample approximation without continuity correction.

Formula

Allele frequencies sum to 1 (p + q = 1, or p + q + r + … = 1). At equilibrium the genotype frequencies are the terms of (p + q)² = p² + 2pq + q² = 1; with more alleles each homozygote is pᵢ² and each heterozygote 2pᵢpⱼ, giving n(n + 1) ÷ 2 genotypes. From genotype counts: p = (2·AA + Aa) ÷ 2N, and χ² = Σ (observed − expected)² ÷ expected with 1 degree of freedom.
  • From the recessive homozygote frequency (for example the prevalence of a recessive disease): q = √(q²), p = 1 − q, carriers = 2pq.
  • From the homozygous dominant frequency: p = √(p²). From the dominant phenotype (p² + 2pq): q = √(1 − (p² + 2pq)).
  • From the carrier frequency h = 2pq: q = (1 − √(1 − 2h)) ÷ 2. This requires h ≤ 0.5, the largest value 2pq can take (at p = q = 0.5). The other root, (1 + √(1 − 2h)) ÷ 2, is shown too, because 2pq alone cannot say which allele is rarer.
  • '1 in X' values are simply X = 1 ÷ frequency; for carriers X = 1 ÷ 2pq.
  • Chi-square test: expected counts are p²N, 2pqN and q²N using p and q estimated from the same sample, so there is 3 − 1 − 1 = 1 degree of freedom. The p-value is the upper tail of the χ² distribution with 1 df, erfc(√(χ²/2)); χ² ≥ 3.841 means p < 0.05.
  • The inbreeding coefficient F = 1 − Hobs ÷ Hexp is positive when there are fewer heterozygotes than expected (inbreeding, population structure, genotyping errors) and negative when there are more.

MN blood group sample

Inputs
  • What do you know?: counts
  • AA (homozygous dominant): 1787
  • Aa (heterozygous): 3039
  • aa (homozygous recessive): 1303

A classic sample of 6,129 people typed for the MN blood group had 1,787 MM, 3,039 MN and 1,303 NN. p = (2 × 1,787 + 3,039) ÷ 12,258 = 0.5395 and q = 0.4605. Expected counts are p² × 6,129 ≈ 1,783.81, 2pq × 6,129 ≈ 3,045.39 and q² × 6,129 ≈ 1,299.81. The deviations are tiny, χ² ≈ 0.027 (p ≈ 0.87, far above 0.05), so the sample fits Hardy–Weinberg proportions.

Sources & references

Frequently asked questions

What does p² + 2pq + q² = 1 mean?
If a gene has two alleles with frequencies p and q, and people pair up at random with respect to that gene, then a child receives A from each parent with probability p × p, a from each parent with q × q, and one of each in two ways, 2 × p × q. Those three genotype frequencies cover every possibility, so they add up to 1.
How do I find the carrier frequency of a recessive disease?
Use the disease prevalence as q². For a condition affecting 1 in 10,000 births, q = √0.0001 = 0.01, p = 0.99 and the carrier frequency 2pq = 0.0198, roughly 1 in 50 people. Choose 'One genotype or phenotype frequency', pick the homozygous recessive option and enter N = 10,000.
What conditions are needed for Hardy–Weinberg equilibrium?
The model assumes random mating, a very large population (no genetic drift), no mutation, no migration (gene flow) and no natural selection on the gene. Real populations never meet all five exactly, which is why the equilibrium is used as a null model: a significant departure hints that one of these forces, or a genotyping problem, is at work.
How do I test whether my sample is in Hardy–Weinberg equilibrium?
Enter the observed AA, Aa and aa counts. The calculator estimates p and q from those counts, works out the expected counts p²N, 2pqN and q²N, and compares them with a chi-square test with one degree of freedom. A χ² above 3.841 (p < 0.05) suggests a departure. With small samples, or when an expected count is under 5, an exact test is more reliable than χ².
Can I use more than two alleles?
Yes. With n alleles there are n homozygotes (p², q², r², …) and n(n − 1) ÷ 2 heterozygotes (2pq, 2pr, 2qr, …), so n(n + 1) ÷ 2 genotypes in total: 6 for three alleles, 10 for four and 15 for five. The ABO blood group is a familiar three-allele example.
Why can't I get p from the carrier frequency uniquely?
Because 2pq gives the same value if p and q are swapped. A carrier frequency of 0.42 fits both q = 0.3 and q = 0.7. The calculator assumes the recessive allele is the rarer one, which is the usual situation for disease alleles, and lists the other solution as well.

Related calculators

Allele Frequency Calculator Works out allele frequencies three ways. From the prevalence of a recessive condition (as '1 in N' or a percentage) it finds the disease allele frequency q, the normal allele frequency p, the share of non-carriers, carriers and affected people, and the carrier rate as '1 in X'. From AA, Aa and aa genotype counts it counts alleles to get p, q and the minor allele frequency, and from raw allele counts it handles up to five alleles. Punnett Square Calculator Builds the 2 × 2 Punnett square for a single gene. Pick each parent's genotype (AA, Aa or aa) and the calculator lists the gametes, fills the grid, and gives the chance of every offspring genotype and phenotype with the genotypic and phenotypic ratios. It handles complete dominance and incomplete dominance or codominance, and shows how many offspring with the dominant trait are hidden carriers. Dihybrid Cross Punnett Square Calculator Builds the 4 × 4 Punnett square for two independently inherited genes. Choose each parent's genotype for gene A (AA, Aa or aa) and gene B (BB, Bb or bb); the calculator lists each parent's four gametes, fills all 16 boxes, and gives the probability of all nine genotypes and four phenotypes along with the reduced genotypic and phenotypic ratios, such as 9 : 3 : 3 : 1 for AaBb × AaBb. Population Growth Calculator Projects the size of a biological population — bacteria, plants, animals or people — from its starting size, growth rate and elapsed time, or works backwards to the starting size, the growth rate or the time needed to reach a target. Choose a percentage rate per period, a continuous rate, a doubling time, or logistic growth limited by a carrying capacity, set separate units for the rate period and the time, and see the change, equivalent rates, doubling or halving time and a time-series table.