Hardy–Weinberg Equilibrium Calculator
Check whether genotype counts fit Hardy–Weinberg equilibrium. Get the allele frequencies p and q, the expected p², 2pq and q² counts and a chi-square test with its p-value, or work out carrier frequency from how common a recessive condition is.
How to Use
- Choose a mode: Genotype counts to test a sample, Allele frequency to get the expected genotype frequencies, or Disease incidence to estimate carriers.
- For counts, enter how many individuals are AA, Aa and aa. The tool works out p and q from those counts.
- For an allele frequency, enter p between 0 and 1 and, if you like, a population size to get expected numbers.
- For incidence, enter how common the recessive condition is as “1 in …”, for example 2500.
- Read p, q, the chi-square value and its p-value in the readouts; the square shows p² + 2pq + q² as areas and Show Work lists the test step by step.
Worked Example
Testing a sample. 1,000 people are genotyped: 380 AA, 440 Aa and 180 aa. Allele A makes up p = (2 × 380 + 440) ÷ 2,000 = 0.6 of the 2,000 gene copies, so q = 0.4. The expected counts are 1,000 × 0.36 = 360 AA, 1,000 × 0.48 = 480 Aa and 1,000 × 0.16 = 160 aa. χ² = (380 − 360)² ÷ 360 + (440 − 480)² ÷ 480 + (180 − 160)² ÷ 160 = 1.111 + 3.333 + 2.5 = 6.944. With 1 degree of freedom, P = 0.0084, below 0.05: the sample is not in Hardy–Weinberg equilibrium and has too few heterozygotes.
Carriers from incidence. If a recessive condition affects 1 in 2,500 people (an illustrative figure of the size often quoted for cystic fibrosis), q² = 0.0004, q = 0.02, p = 0.98 and carriers are 2pq = 0.0392, about 1 in 25.51.
The common mistake: using the incidence as the allele frequency. Taking q = 0.0004 instead of √0.0004 gives a carrier frequency of 2 × 0.9996 × 0.0004 = 0.0008, about 1 in 1,251, nearly 50 times too low. The incidence is q², the frequency of people with two copies; the allele frequency is its square root.
Show Work
Formulas
Hardy, Weinberg and a Question from Punnett
After Mendel’s work was rediscovered in 1900, some critics argued that a dominant allele ought to spread until three quarters of a population showed the dominant trait. At Cambridge the geneticist Reginald Punnett put the question to the mathematician G. H. Hardy, who answered it in a short letter to Science in 1908, “Mendelian proportions in a mixed population”: without selection, the allele frequencies stay where they are and the genotypes settle at p², 2pq and q² after one generation of random mating.
The German physician Wilhelm Weinberg reached the same result independently in a lecture in Stuttgart the same year, and the principle carries both names. The American geneticist William Castle had described a special case in 1903.
Because the proportions hold only when nothing disturbs them, a departure from Hardy–Weinberg proportions is a signal: inbreeding, selection, migration, a sample drawn from two populations, or, in modern genotyping, errors in the data. The chi-square test on this page is the standard first check.
About This Tool
This calculator estimates allele frequencies from genotype counts, compares the counts with the Hardy–Weinberg expectation using a chi-square goodness-of-fit test with one degree of freedom, and gives the exact p-value from the chi-square distribution together with the observed and expected heterozygosity. It also turns an allele frequency into expected genotype frequencies and numbers, and a recessive-condition incidence into the allele and carrier frequencies. It warns when expected counts are too small for the chi-square approximation.
Everything runs in your browser; nothing you enter is sent anywhere. Disease figures on this page are illustrative, not clinical data.
Related tools: Punnett Square Calculator, Probability Calculator, and Statistics Calculator.
Frequently Asked Questions
What is the Hardy–Weinberg equation?
For a gene with two alleles at frequencies p and q (p + q = 1), random mating gives genotype frequencies p² (AA), 2pq (Aa) and q² (aa), which add to 1. With p = 0.7 and q = 0.3 they are 0.49, 0.42 and 0.09, so in 500 people you expect 245 AA, 210 Aa and 45 aa.
How do I test whether a population is in Hardy–Weinberg equilibrium?
Estimate p from the counts, work out the expected counts and compare them with a chi-square test. For 355 AA, 490 Aa and 155 aa (n = 1,000), p = (2 × 355 + 490) ÷ 2,000 = 0.6, the expected counts are 360, 480 and 160, and χ² = 0.434 with P = 0.51, so there is no evidence against equilibrium.
Why does the chi-square test have only 1 degree of freedom?
There are 3 genotype classes, minus 1 because the counts must add to n, minus 1 more because p was estimated from the same data. With df = 1 the 5% critical value is 3.841. Counts of 380, 440 and 180 give χ² = 6.944, above 3.841, with P = 0.0084: too few heterozygotes for equilibrium.
How do I work out carrier frequency from disease incidence?
For a recessive condition, the affected frequency is q², so q = √incidence and carriers are 2pq. Cystic fibrosis is the textbook example: with an illustrative incidence of 1 in 2,500, q = √0.0004 = 0.02, p = 0.98, and 2pq = 0.0392, about 1 in 25.51 people, or 98 carriers for every affected person.
What assumptions does Hardy–Weinberg equilibrium make?
Random mating, no selection, no mutation, no migration, and a population large enough that chance (genetic drift) does not shift the frequencies. Breaking them shows up in the test: inbreeding, for example, reduces heterozygotes, as in the 380/440/180 sample where only 0.44 of people are Aa against an expected 0.48.
How do I use the Hardy–Weinberg Equilibrium Calculator?
Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.
Does it cost anything or need an account?
No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.
Is anything I type uploaded?
No. The tool works entirely on your device, so the values you enter never leave your browser.
Common Use Cases
Genetics coursework
A sample of 355 AA, 490 Aa and 155 aa gives p = 0.6, q = 0.4 and χ² = 0.434 (P = 0.51), consistent with equilibrium.
Genotyping quality control
A marker with 380/440/180 calls fails at χ² = 6.944 (P = 0.0084), a common flag for genotyping errors or a mixed sample.
Carrier estimates
A recessive condition affecting 1 in 10,000 people implies q = 0.01 and carriers at 1.98%, about 1 in 50.51.
Predicting genotypes
An allele at p = 0.7 predicts 245 AA, 210 Aa and 45 aa among 500 people.
Showing hidden variation
At 1 in 2,500 affected, carriers outnumber affected people 98 to 1, which is why recessive alleles persist.
Last updated: