Hardy-Weinberg Equilibrium Calculator
Work out allele frequencies p and q, the expected genotype frequencies p², 2pq and q², and test whether a sample is in Hardy-Weinberg equilibrium with a chi-square test. Start from observed genotype counts, a known allele frequency, or the share of the population showing the recessive trait.
Last updated:
dominant / recessive shown as A / a
1 in 2,500 = 0.04%
to show expected numbers of individuals
How to use the Hardy-Weinberg Equilibrium Calculator
- Choose what you know: genotype counts, one allele frequency, or the percentage with the recessive phenotype.
- Enter your numbers, e.g. 360 AA, 480 Aa and 160 aa, or q² = 4%.
- Pick a significance level for the chi-square test (0.05 is standard).
- Press Calculate to see p, q, the expected genotype frequencies and, for counts, the χ² test result.
- Read the step-by-step working and download the observed vs expected table as CSV.
Hardy-Weinberg formulas at a glance
| Quantity | Formula | Meaning |
|---|---|---|
| Allele frequencies | p + q = 1 | p = share of A alleles, q = share of a alleles |
| Genotype frequencies | p² + 2pq + q² = 1 | AA, Aa and aa in an equilibrium population |
| p from counts | (2·AA + Aa) / 2N | count alleles, not individuals |
| q from a recessive trait | q = √(aa frequency) | only valid if the population is in equilibrium |
| Carriers | 2pq | heterozygotes who carry one recessive allele |
| Chi-square | Σ (O − E)² / E, df = 1 | critical value 3.841 at α = 0.05 |
Recessive trait frequency vs carrier frequency
A useful pattern: when a recessive allele is rare, carriers far outnumber affected individuals, because 2pq is much larger than q². The table below uses the equilibrium formulas.
| Affected (q²) | q | p | Carriers (2pq) | Carriers per affected |
|---|---|---|---|---|
| 25% (1 in 4) | 0.5 | 0.5 | 50% (1 in 2) | 2 |
| 16% (1 in 6.25) | 0.4 | 0.6 | 48% | 3 |
| 4% (1 in 25) | 0.2 | 0.8 | 32% | 8 |
| 1% (1 in 100) | 0.1 | 0.9 | 18% (1 in 5.6) | 18 |
| 0.04% (1 in 2,500) | 0.02 | 0.98 | 3.92% (1 in 25.5) | 98 |
| 0.01% (1 in 10,000) | 0.01 | 0.99 | 1.98% (1 in 50.5) | 198 |
Interpreting the chi-square result
- p-value ≥ α: the observed counts are consistent with Hardy-Weinberg proportions. This does not prove equilibrium, it only means the sample gives no evidence against it.
- p-value < α: the genotype counts deviate from p², 2pq, q². Look at which class is off: too few heterozygotes suggests inbreeding, population substructure (the Wahlund effect) or allele dropout in genotyping; too many can point to heterozygote advantage or mixing of two source populations.
- Small samples: if any expected count is below 5 the chi-square approximation is weak. Collect more data or use an exact test.
- More than two alleles: the same idea extends to (p + q + r)² = 1, but this calculator handles the common two-allele case.
Frequently asked questions
What is the Hardy-Weinberg equation?
For a gene with two alleles at frequencies p and q (p + q = 1), a population in equilibrium has genotype frequencies p² (AA), 2pq (Aa) and q² (aa), and p² + 2pq + q² = 1. The proportions stay the same from generation to generation when no evolutionary forces act.
How do you calculate p and q from genotype counts?
Count alleles: each AA individual carries two A alleles and each Aa carries one. p = (2 × AA + Aa) / (2 × N) and q = (2 × aa + Aa) / (2 × N), where N is the total number of individuals. With 360 AA, 480 Aa and 160 aa, p = (720 + 480) / 2000 = 0.6 and q = 0.4.
How do I find carrier frequency from the number of affected people?
If a recessive condition affects 1 in 2,500 people, q² = 0.0004, so q = √0.0004 = 0.02 and p = 0.98. Carriers (heterozygotes) make up 2pq = 2 × 0.98 × 0.02 ≈ 0.039, or about 1 in 26. Enter 0.04% in the recessive phenotype mode to get this.
How does the chi-square test for Hardy-Weinberg work?
The calculator estimates p from your sample, computes the expected counts p²N, 2pqN and q²N, and adds up (observed − expected)² / expected for the three genotypes. There is 1 degree of freedom (3 classes minus 1, minus 1 for the estimated allele frequency). At α = 0.05 the critical value is 3.841; a larger χ² means the sample deviates from equilibrium.
What are the assumptions of Hardy-Weinberg equilibrium?
A very large population, random mating, no mutation, no migration (gene flow) and no natural selection. Real populations rarely meet every condition, which is why a significant deviation is a useful signal that one of these forces, or a sampling or genotyping problem, is at work.
Can I use Hardy-Weinberg if I only know the dominant phenotype?
Not directly, because AA and Aa look the same. Use the recessive phenotype instead: its frequency equals q², so q = √(recessive frequency). If you know the dominant share, subtract it from 100% to get the recessive share.
What does the inbreeding coefficient F mean here?
F = 1 − (observed heterozygosity / expected heterozygosity). A value near 0 fits random mating, a positive F means fewer heterozygotes than expected (as with inbreeding or population substructure), and a negative F means an excess of heterozygotes.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.