PublicSoftTools

Hardy-Weinberg Equilibrium Calculator

Calculate allele and genotype frequencies using the Hardy-Weinberg equation p² + 2pq + q² = 1. Enter allele frequency p directly or calculate from observed genotype counts. Includes visual bar chart and verification. No signup, runs entirely in your browser.

⏱ 10 min read · Complete guide below

q = 1 − p = 0.4000

How to Use the Hardy-Weinberg Calculator

  1. 1Choose your input mode — enter the allele frequency p directly, or switch to genotype counts.
  2. 2If a question gives the recessive phenotype frequency, that value is — take its square root to get q, then p = 1 − q.
  3. 3Read the three genotype frequencies — p² (AA), 2pq (Aa), q² (aa) — and the verification that they sum to 1.
  4. 4Use the bar chart to compare carrier frequency (2pq) against affected frequency (q²).

Worked Example: Cystic Fibrosis Carrier Frequency

Cystic fibrosis is a recessive condition affecting roughly 1 in 2,500 people of European descent. That affected frequency is q², so q = √(1/2500) = 1/50 = 0.02. The dominant allele frequency is p = 1 − 0.02 = 0.98. The carrier frequency — heterozygotes who show no symptoms but can pass the allele on — is 2pq = 2 × 0.98 × 0.02 = 0.0392, or about 1 in 25 people.

That result is the reason the equation matters for public health: only 1 in 2,500 people have the disease, but 1 in 25 carry it — a hundred times more common. The carriers are the hidden reservoir of the allele, which is why genetic screening targets prospective parents rather than just affected individuals. Whenever q is small, 2pq dwarfs q², and this calculator makes that gap immediately visible in the bar chart.

What the Hardy-Weinberg Principle Says

The Hardy-Weinberg principle is the foundation of population genetics. It states that, in a large population that is not evolving, both allele frequencies and genotype frequencies stay constant from one generation to the next. The two allele frequencies are written as p (dominant) and q (recessive), which must sum to 1, and the three genotype frequencies follow the equation p² + 2pq + q² = 1 — where p² is the homozygous dominant proportion, 2pq the heterozygotes, and q² the homozygous recessives. Its real power is as a null model: it predicts what a population would look like if nothing were changing it, so any deviation from these expected frequencies is a signal that some evolutionary force is at work.

The Five Conditions for Equilibrium

For a population to stay in Hardy-Weinberg equilibrium, five assumptions must hold: no mutation altering the alleles, no migration (gene flow) in or out, random mating with no preference for particular genotypes, a very large population so chance (genetic drift) has negligible effect, and no natural selectionfavouring any genotype. No real population meets all five perfectly, and that is precisely the point: each condition corresponds to one of the mechanisms of evolution. When observed genotype frequencies drift away from the Hardy-Weinberg prediction, it tells a biologist that one of these forces — selection, drift, gene flow, non-random mating, or mutation — is acting on the trait.

Why Carrier Frequency Matters

One of the most practically important results the equation delivers is the carrier frequency, 2pq — the proportion of heterozygotes who carry a recessive allele without showing the trait. As the cystic-fibrosis example shows, when a recessive allele is rare, carriers vastly outnumber affected individuals: a condition affecting 1 in 2,500 people can have carriers at roughly 1 in 25, a hundredfold difference. This hidden reservoir of alleles is why recessive conditions persist in populations and why genetic screening focuses on identifying carriers among prospective parents, not just diagnosing affected individuals. The bar chart in this calculator makes the gap between the small q² and the much larger 2pq immediately visible for any allele frequency you enter.

Hardy-Weinberg Revision Tips

Start from the recessive phenotype

Exam questions usually give you the frequency of the recessive phenotype (e.g. "1 in 10,000 have albinism"). That frequency is q². Take the square root to get q, then p = 1 − q, and calculate the rest.

Remember p + q = 1

This constraint is separate from the genotype equation. Since there are only two alleles (A and a), their frequencies must sum to 1. Always check: if p = 0.7, then q must be 0.3.

Carrier frequency

The heterozygote (carrier) frequency 2pq is often the key result. For a rare recessive allele (small q), the carrier frequency 2pq is much larger than the q² frequency of affected individuals — this matters for genetic screening.

Testing HWE in practice

Real populations rarely meet all five HWE conditions simultaneously. Chi-squared tests compare observed genotype frequencies to HWE-predicted frequencies to determine whether the deviation is statistically significant.

The History and the Debate It Settled

The principle is named after two people who arrived at it independently in 1908: the English mathematician G. H. Hardy and the German physician Wilhelm Weinberg. Hardy, a pure mathematician who reportedly considered the result almost too trivial to publish, wrote it up to settle a genuine confusion among biologists of the day. In the early years after Mendel's work was rediscovered, some argued that a dominant allele must inevitably increase in frequency over generations and eventually swamp the recessive one — that dominance itself was a kind of evolutionary force.

Hardy's simple algebra showed this was wrong. Dominance describes how alleles are expressed, not how common they are; in the absence of forces that change allele frequencies, both the alleles and the genotype proportions stay perfectly stable generation after generation. A rare recessive allele does not disappear, and a common dominant one does not take over — they simply persist in the fixed relationship the equation describes. Settling that misconception gave genetics its baseline, and that is why a one-line equation from 1908 remains the foundation of population genetics today.

Using Hardy-Weinberg to Detect Evolution

The real genius of the principle is that it works as a null model — a description of what a population looks like when nothing is changing it. Because no real population perfectly meets all five conditions, the equilibrium is rarely exactly true; and that is the point. When observed genotype frequencies deviate from what the equation predicts, the deviation is a clue, and its pattern points toward which evolutionary force is at work: selection, genetic drift, gene flow, mutation, or non-random mating.

A famous real-world example is the sickle-cell allele. In regions where malaria is common, the allele persists at frequencies far higher than a harmful recessive condition “should” allow, because heterozygous carriers gain resistance to malaria — a case of balancing selection that shows up precisely as a departure from Hardy-Weinberg expectations. Biologists use the equation exactly this way: compute the expected genotype frequencies, compare them with the observed counts (often with a chi-squared test to judge whether the difference is significant), and let the mismatch reveal the biology. The calculator's genotype-counts mode is built for this comparison.

Applications Beyond the Classroom

Though it is a staple of biology exams, the Hardy-Weinberg principle earns its keep in serious science and medicine. In public health and genetic counselling, it turns a disease's incidence into a carrier frequency — as the cystic-fibrosis example shows, revealing that carriers vastly outnumber affected individuals, which is the basis for who gets screened. In forensic DNA profiling, the frequencies of genetic markers in a population, assumed to be in equilibrium, are what let analysts calculate how rare a given DNA profile is and therefore how strong a match is.

Conservation genetics uses the principle to monitor small, endangered populations, where a departure from equilibrium can flag inbreeding or loss of genetic diversity that threatens the population's survival. And across evolutionary biology, it remains the reference point against which change is measured. For all these uses, the underlying calculation is the same handful of steps this tool performs — take an allele frequency or a set of genotype counts, apply p² + 2pq + q² = 1, and read off the frequencies — which is why becoming fluent with it opens a door far wider than any single exam question.

Frequently Asked Questions

What is Hardy-Weinberg equilibrium?

Hardy-Weinberg equilibrium describes a theoretical population where allele frequencies remain constant generation to generation in the absence of evolution. It requires: no mutation, no migration, random mating, very large population, and no natural selection.

What is the Hardy-Weinberg equation?

p² + 2pq + q² = 1, where p is the frequency of the dominant allele (A) and q is the frequency of the recessive allele (a). p² represents homozygous dominant (AA) frequency, 2pq represents heterozygous (Aa) frequency, and q² represents homozygous recessive (aa) frequency.

How do I find p if I only know q²?

If you know the frequency of the recessive phenotype, that equals q² (since only aa individuals express it). Take the square root to get q, then p = 1 − q. This is the most common exam calculation.

When is a population NOT in Hardy-Weinberg equilibrium?

A population deviates from HWE when any of the five conditions are violated: natural selection acts on the trait, there is non-random mating (inbreeding or assortative mating), mutations occur, individuals migrate in or out, or the population is small (genetic drift occurs).

What does the "from genotype counts" mode do?

Enter the observed counts of homozygous dominant (AA), heterozygous (Aa), and homozygous recessive (aa) individuals. The calculator computes allele frequencies from these counts and then applies the HWE equation. This lets you test whether an observed population matches HWE predictions.

Is my data sent anywhere?

No. All calculations are performed locally in your browser.

Why must all five Hardy-Weinberg conditions hold?

Each of the five conditions — no mutation, no migration, random mating, a very large population, and no natural selection — blocks one of the mechanisms that change allele frequencies. If any is violated, the population can evolve and the predicted equilibrium frequencies no longer hold. That is exactly why the principle is so useful: because real populations rarely meet all five, a deviation from the predicted frequencies points to which evolutionary force is acting.

What is the difference between allele frequency and genotype frequency?

Allele frequency is the proportion of a particular allele among all copies of the gene in the population — these are p and q, which sum to 1. Genotype frequency is the proportion of individuals with a particular pair of alleles: p² for homozygous dominant (AA), 2pq for heterozygous (Aa), and q² for homozygous recessive (aa). The Hardy-Weinberg equation connects the two, predicting genotype frequencies from allele frequencies.

How do I calculate carrier frequency from the incidence of a recessive disease?

Start with the disease incidence, which equals q² since only homozygous recessive individuals are affected. Take the square root to get q, then find p = 1 − q. The carrier frequency is 2pq. For example, a disease affecting 1 in 10,000 gives q = 0.01, p = 0.99, and a carrier frequency of 2 × 0.99 × 0.01 ≈ 0.0198, or about 1 in 50 — far more common than the affected rate.

Can I test whether a real population is in Hardy-Weinberg equilibrium?

Yes. Use the genotype-counts mode to enter the observed numbers of AA, Aa, and aa individuals. The calculator derives the allele frequencies and shows the genotype frequencies the equation predicts, so you can compare observed with expected. To decide whether any difference is statistically significant rather than chance, biologists apply a chi-squared test comparing the observed and expected genotype counts.

Why does the recessive phenotype frequency equal q² and not q?

Because an individual only shows a recessive trait if they inherit two recessive alleles (genotype aa). The chance of inheriting one recessive allele is q, and inheriting two independently is q × q = q². Heterozygotes (Aa), who have one recessive allele, do not show the trait because the dominant allele masks it. So the observable recessive phenotype frequency corresponds to q², which is why you square-root it to recover the allele frequency q.