Hardy–Weinberg Equilibrium Calculator
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
- 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
- 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.