Hardy-Weinberg Calculator
- With one locus and two alleles, q = 1 - p = 1 - 0.7 = 0.30.
- Random mating distributes the alleles as (p + q)^2: AA = p^2 = 49.00%, Aa = 2pq = 42.00%, aa = q^2 = 9.00%.
- Check: 49.00 + 42.00 + 9.00 = 100% of the population, and the allele frequencies come back out unchanged - that stability across generations is the Hardy-Weinberg equilibrium.
- The equilibrium assumes random mating, no selection, no mutation, no migration and a large population; real populations deviate, and the size of the deviation is itself informative.
This hardy weinberg calculator turns allele frequencies into expected genotype frequencies using the Hardy-Weinberg equilibrium, which distributes two alleles as (p + q)^2: p^2, 2pq and q^2, with q = 1 - p. Enter p and it returns the share of AA, Aa and aa. At p = 0.7, for example, the population is 49.00% AA, 42.00% Aa and 9.00% aa, and the allele frequencies come back out unchanged in the next generation. The calculator also shows how rare a recessive genotype can be while carriers remain common: at p = 0.99, only 0.01% are aa while 1.98% are carriers, which is why rare recessive alleles persist hidden in populations. If you have genotype counts instead, gene counting recovers the allele frequency — 560 AA, 280 Aa and 160 aa in 1,000 individuals give p = 0.7000.
The method behind the answer is the standard one taught in genetics: expected frequencies from (p + q)^2, allele frequencies from gene counting, and a chi-square test to judge whether observed counts fit equilibrium. Those same counts are far from equilibrium — expected counts are 490.0, 420.0 and 90.0, giving a chi-square of 111.11 on 1 degree of freedom, well above the 3.84 threshold for the 5% level. This page shows the formula, step-by-step workings, worked examples and sources so you can check every number yourself.
Worked examples
From allele frequency p = 0.7
Recessive allele frequency q = 0.30. AA (homozygous dominant): 49.00%; Aa (heterozygous): 42.00%; aa (homozygous recessive): 9.00%. (Allele frequency p · 0.7 · 0 · 0 · 0)
| Recessive allele frequency q | 0.30 |
| AA (homozygous dominant) | 49.00% |
| Aa (heterozygous) | 42.00% |
| aa (homozygous recessive) | 9.00% |
Rare recessive allele, p = 0.99
Recessive allele frequency q = 0.01. AA (homozygous dominant): 98.01%; Aa (heterozygous): 1.98%; aa (homozygous recessive): 0.01%. (Allele frequency p · 0.99 · 0 · 0 · 0)
| Recessive allele frequency q | 0.01 |
| AA (homozygous dominant) | 98.01% |
| Aa (heterozygous) | 1.98% |
| aa (homozygous recessive) | 0.01% |
Counts 560 / 280 / 160 (off equilibrium)
Dominant allele frequency p = 0.7000. Expected AA / Aa / aa: 490.0 / 420.0 / 90.0; Chi-square (df = 1): 111.11; Equilibrium verdict: Above 3.84, so the population deviates from Hardy-Weinberg equilibrium at the 5% level. (Observed genotype counts · 0.5 · 560 · 280 · 160)
| Dominant allele frequency p | 0.7000 |
| Expected AA / Aa / aa | 490.0 / 420.0 / 90.0 |
| Chi-square (df = 1) | 111.11 |
| Equilibrium verdict | Above 3.84, so the population deviates from Hardy-Weinberg equilibrium at the 5% level |
The equilibrium idea
Hardy-Weinberg equilibrium rests on a single algebraic idea: if you square the sum of the two allele frequencies, you get the genotype frequencies. Write the frequency of one allele as p and the other as q, so that q = 1 - p. Then (p + q)^2 expands to p^2 for the homozygote of the first allele, 2pq for the heterozygote, and q^2 for the homozygote of the second allele. That is the whole pattern. What makes it remarkable is not the algebra but what the algebra implies about time: under the model's conditions, these frequencies do not drift from one generation to the next. They lock in and stay there.
A worked example shows the lock. Set p = 0.7, so q = 0.3. Squaring gives 49.00% AA, 42.00% Aa and 9.00% aa. Now let those individuals mate at random and compute the allele frequencies in the next generation from the genotypes they produce. The frequencies come back out unchanged: p is still 0.7. The population has reached a fixed point, and no further change follows unless something disturbs it. This is why a hardy weinberg calculator is useful as a baseline — it tells you what a population would look like if nothing were happening to it, which is exactly the comparison you need before claiming that something is.
The conditions behind that fixed point are worth stating plainly: random mating and no evolutionary forces. In practice that means no selection, no mutation, no migration and no genetic drift, and a population large enough that chance fluctuations can be ignored. The 1908 result is that when these hold, allele and genotype frequencies settle into the p^2, 2pq, q^2 pattern and remain there. The model is an idealization, not a description of every real population, and its value comes from being a precise null hypothesis rather than a rough guess.
The pattern also explains something counterintuitive about rare alleles. At p = 0.99, the recessive genotype nearly vanishes: only 0.01% of the population is aa. Yet 1.98% are carriers. The recessive allele is still present in the population, but almost all of it is hidden inside heterozygotes that show no recessive trait. This is why rare recessive alleles persist in populations instead of being eliminated — the rarer the allele, the greater the share of its copies that sit in carriers.
Real data rarely match the expectation, and the mismatch is the point. Suppose you count 560 AA, 280 Aa and 160 aa among 1,000 individuals. Gene counting recovers the allele frequency directly: p = 0.7000. But those same counts are far from equilibrium. The expected counts at p = 0.7 are 490.0, 420.0 and 90.0, and comparing observed with expected gives a chi-square of 111.11 on 1 degree of freedom — well above the 3.84 threshold for the 5% level. The allele frequency and the genotype frequencies are telling different stories, and a test of Hardy-Weinberg equilibrium is what separates them.
From allele frequency to genotypes
Hardy-Weinberg equilibrium describes how two alleles at one locus are distributed among genotypes. If the dominant allele has frequency p and the recessive allele has frequency q, with q = 1 - p, the genotype frequencies are p^2 for AA, 2pq for Aa and q^2 for aa. This is the expansion of (p + q)^2, and it is the arithmetic behind every hardy weinberg calculator: you supply the allele frequencies, and the square tells you the expected share of each genotype.
Take p = 0.7, so q = 0.3. Squaring p gives 0.49, doubling the product of p and q gives 0.42, and squaring q gives 0.09. In percentage terms the population is 49.00% AA, 42.00% Aa and 9.00% aa. The check that makes the model useful is the next generation: if those genotypes mate at random, the allele frequencies come back out unchanged. The distribution holds steady, which is why it is called an equilibrium.
The p = 0.99 case shows why recessive disease alleles are so hard to remove. Here q = 0.01, so the recessive genotype aa is q^2 = 0.0001, or 0.01% of the population. Carriers, the heterozygotes, are 2pq = 2 times 0.99 times 0.01, which is 0.0198, or 1.98%. That is roughly 200 times more carriers than affected individuals. Most copies of a rare recessive allele sit in people who show no sign of the condition, so the allele persists largely hidden from selection. This is the lesson the calculator makes visible: shrinking q shrinks q^2 far faster than it shrinks 2pq.
Real data rarely arrive as frequencies, so the calculator also works from counts. Suppose 1,000 individuals are typed as 560 AA, 280 Aa and 160 aa. Gene counting recovers the allele frequency: each AA contributes two A alleles and each Aa contributes one, so p = (2 times 560 + 280) divided by 2,000, which is 0.7000. Compare those observed counts with the equilibrium expectations for p = 0.7. The expected counts are 490.0 AA, 420.0 Aa and 90.0 aa. A chi-square test on these numbers gives 111.11 on 1 degree of freedom. The 5% threshold for 1 degree of freedom is 3.84, so 111.11 is far above it and the population is not in equilibrium.
Testing real populations with chi-square
A hardy weinberg calculator is most useful when you start from real genotype counts rather than an assumed allele frequency. Gene counting is the bridge. Suppose you have 1,000 individuals typed at one locus: 560 AA, 280 Aa and 160 aa. Each AA individual carries two A alleles, each Aa carries one, and each aa carries none, so the A count is 560 × 2 + 280 = 1,400 out of 2,000 total alleles. That gives p = 1,400 / 2,000 = 0.7000, and q = 1 − p = 0.3000.
Now compare those observed counts with what Hardy-Weinberg equilibrium predicts at p = 0.7. The expected genotype proportions are p^2 = 0.49, 2pq = 0.42 and q^2 = 0.09. Scaled to 1,000 individuals, the expected counts are 490.0 AA, 420.0 Aa and 90.0 aa. The observed population has more homozygotes on both sides (560 AA and 160 aa) and fewer heterozygotes (280 Aa) than equilibrium allows.
The chi-square test measures how far the observed counts sit from those expected counts. For this example the statistic is 111.11 on 1 degree of freedom, since a two-allele locus with known allele frequency leaves one independent genotype class to test. The 5% critical value at 1 degree of freedom is 3.84. A value of 111.11 is far above 3.84, so the deviation is not consistent with Hardy-Weinberg equilibrium at the 5% level.
The direction of the deviation matters as much as its size. An excess of both homozygotes with a deficit of heterozygotes is the classic signature of population structure, inbreeding or genotyping problems such as allelic dropout, though the test alone cannot say which. A significant result is a prompt to look at the data, not proof of any single cause.
Equilibrium itself is easy to check once you have p. At p = 0.7 the population is 49.00% AA, 42.00% Aa and 9.00% aa, and the allele frequencies come back out unchanged in the next generation. That stability is what makes the expected counts a meaningful baseline. It also explains why rare recessive alleles persist: at p = 0.99 the recessive genotype nearly vanishes at 0.01% aa, while 1.98% are carriers, so the allele stays hidden in heterozygotes where selection cannot see it.
- Observed: 560 AA, 280 Aa, 160 aa in 1,000 individuals → p = 0.7000
- Expected at p = 0.7: 490.0 AA, 420.0 Aa, 90.0 aa
- Chi-square = 111.11 on 1 degree of freedom
- Critical value at the 5% level = 3.84 → reject equilibrium
Why populations deviate
A hardy weinberg calculator tells you what genotype frequencies to expect when a population meets a strict set of conditions, and a significant deviation tells you one of those conditions is being broken. The model assumes random mating, no selection, no mutation, no migration and no genetic drift — that is, a large population in which allele frequencies stay put. In practice, real populations rarely satisfy all five at once, so the value of the test lies less in confirming equilibrium than in asking which assumption failed when the numbers do not fit.
Random mating is the assumption most often broken, and when individuals choose partners by relatedness or by trait, genotype frequencies shift even if allele frequencies hold steady. Selection changes genotype frequencies by giving some genotypes more surviving offspring than others. Mutation introduces new alleles slowly, and migration, or gene flow, brings alleles in from another population. Drift is the random change in allele frequencies that matters most in small populations. Each violation pushes the observed counts away from the p^2, 2pq and q^2 pattern the model predicts.
A worked contrast shows how much signal a deviation can carry. At p = 0.7, equilibrium gives 49.00% AA, 42.00% Aa and 9.00% aa, and those allele frequencies come back out unchanged in the next generation. Now take counts of 560 AA, 280 Aa and 160 aa in 1,000 individuals. Gene counting recovers p = 0.7000, identical to the equilibrium case, yet the expected counts are 490.0, 420.0 and 90.0. The chi-square comes to 111.11 on 1 degree of freedom, far above the 3.84 threshold for the 5% level. Same allele frequency, very different genotype structure — the deviation, not the allele frequency, is the finding.
Rare recessive alleles illustrate why hidden variation matters. At p = 0.99 the recessive genotype nearly vanishes at 0.01% aa, while 1.98% of the population are carriers. Most copies of a rare recessive allele therefore sit in heterozygotes, invisible to selection, which is why such alleles persist in populations far longer than their homozygote frequency would suggest.
Read a significant result as a prompt to investigate, not a verdict. Ask whether the excess or deficit of heterozygotes points to inbreeding or population subdivision, whether the sample mixes groups with different allele frequencies, or whether genotyping error or a violated sampling assumption produced the gap. Each of these leaves a different footprint, and checking the raw counts and calling quality is often the fastest way to tell a real biological signal from a technical one.
- Random mating — nonrandom pairing shifts genotype frequencies.
- No selection — genotypes with more offspring change frequencies.
- No mutation — new alleles enter slowly over generations.
- No migration — gene flow imports alleles from elsewhere.
- No drift — small populations fluctuate by chance.
FAQs
How do I calculate genotype frequencies from p?
Square and cross-multiply: AA = p^2, Aa = 2pq, and aa = q^2, with q = 1 - p. At p = 0.7 that gives 49.00% AA, 42.00% Aa, and 9.00% aa. The three frequencies always sum to 100%, so you can check your work by adding them.
Why are there so many carriers of rare recessive alleles?
At p = 0.99, carriers (Aa) are 1.98% while affected (aa) are 0.01%. The 2pq term shrinks far more slowly than q^2, so recessive alleles hide in heterozygotes. Most copies of a rare recessive allele sit in carriers who show no trait, which is why the allele can persist at low frequency.
How do I get p from genotype counts?
Count alleles: p = (2 x AA + Aa) / (2N). With counts 560, 280, and 160 out of 1,000, that gives (1120 + 280) / 2000 = 0.7000. Each AA individual contributes two copies of the allele, each Aa contributes one, and the denominator is twice the total number of individuals.
What chi-square value means equilibrium is rejected?
Above 3.84 at 1 degree of freedom, which is the 5% level. The worked counts give 111.11, decisively off equilibrium. A chi-square above that cutoff means the observed genotype counts differ from Hardy-Weinberg expectations by more than chance alone would likely produce.
What are the Hardy-Weinberg assumptions?
Random mating, no selection, no mutation, no migration, and a population large enough that drift is negligible. When a real population deviates from equilibrium, the deviation points at whichever assumption fails. That makes the model a useful baseline rather than a claim that any real population is perfectly ideal.
Does Hardy-Weinberg apply to humans?
As a baseline, yes. Most human loci sit close to equilibrium, which is exactly why deviations, for example around blood groups or disease loci, are informative. A departure from expected genotype frequencies signals that something such as selection, migration, or nonrandom mating may be acting at that locus.