Hardy-Weinberg Calculator

A Hardy-Weinberg calculator is a population genetics tool that applies the Hardy-Weinberg principle to predict genotype frequencies from allele frequencies (or derive allele frequencies from observed genotype counts). Enter either an allele frequency p or observed AA / Aa / aa counts and the calculator returns the full p squared plus 2pq plus q squared distribution, expected genotype counts for your sample size, carrier frequency, and a visual equilibrium check.

Interactive Genetics Tool

Hardy-Weinberg Calculator

Enter an allele frequency (or observed counts) and the calculator returns the full p squared plus 2pq plus q squared distribution, expected genotype counts for your sample size, and a visual equilibrium check.

Enter a value between 0 and 1 (e.g., 0.7 means 70%).
Number of individuals for expected count calculation.
Try a real scenario

How to Use the Hardy-Weinberg Calculator

  1. Pick your input mode. Use allele frequency mode if you know p (the dominant allele frequency) and want to predict genotype counts. Use observed counts mode if you have real genotype counts from a population and want to derive the allele frequencies.
  2. In allele frequency mode, enter p (a decimal between 0 and 1, like 0.7 for 70%) and a sample size N. The calculator uses the Hardy-Weinberg equation to predict the expected number of AA, Aa, and aa individuals in that sample.
  3. In observed counts mode, enter the number of AA, Aa, and aa individuals you counted. The calculator derives the allele frequencies p and q, then computes expected counts under the Hardy-Weinberg principle.
  4. Read the headline numbers: p, q, p + q (= 1 by definition), and the sample size N. Confirm p + q equals 1.
  5. Check the carrier frequency (the Aa percentage). For recessive diseases, this is the population-wide estimate of how many people carry one disease allele.
  6. Compare observed vs expected (observed mode only). If the observed counts closely match the expected counts, the population is likely in Hardy-Weinberg equilibrium. The visual check here is a quick guide. For formal verification, run a chi-square goodness of fit test.
  7. Use a preset chip to load a real scenario (PKU rare disease, cystic fibrosis carrier frequency, sickle cell polymorphism) for instant comparison.

What Is the Hardy-Weinberg Principle?

The Hardy-Weinberg principle is a foundational model in population genetics. It states that allele frequencies in a population remain constant from generation to generation in the absence of disturbing factors. When a population meets the Hardy-Weinberg assumptions, the genotype frequencies settle into a predictable equilibrium defined by a single equation.

The principle gives population geneticists a baseline. If observed genotype counts deviate from the Hardy-Weinberg expectation, something is acting on the population: natural selection, non-random mating, mutation, migration, genetic drift, or small sample size. Detecting that deviation is the first step toward identifying which evolutionary force is at work.

The Hardy-Weinberg Equation

For a gene with two alleles (A and a), the Hardy-Weinberg equation is:

p2 + 2pq + q2 = 1

where p + q = 1, and the three terms are the expected genotype frequencies

The three terms represent the expected genotype frequencies in any large population under the Hardy-Weinberg equilibrium assumptions:

  • p squared: frequency of homozygous dominant individuals (AA)
  • 2pq: frequency of heterozygous carriers (Aa)
  • q squared: frequency of homozygous recessive individuals (aa)

For a sample of N individuals, the Hardy-Weinberg equation predicts these expected counts: AA count = p squared times N, Aa count = 2pq times N, aa count = q squared times N. These expected genotype frequencies are what an allele frequency population genetics calculation produces when a population is in equilibrium.

How the Hardy-Weinberg Calculator Works

This Hardy-Weinberg equation solver does one of two things depending on which input you provide:

It works as both an allele frequency calculator (forward mode) and a population genetics calculator (reverse mode), letting you go from p to expected counts or from observed counts back to p depending on what your data supports.

  • Allele frequency mode: you give p. The calculator derives q = 1 – p, then computes p squared, 2pq, and q squared. With your sample size N, it returns expected counts for AA, Aa, and aa.
  • Observed counts mode: you give the AA, Aa, and aa counts. The calculator computes N (the total), then solves for p and q using the formulas p = (2 times AA plus Aa) / (2N) and q = 1 – p. It then computes expected counts under equilibrium and compares them to what you observed.

The carrier frequency calculator output (the 2pq term) is what gives the Hardy-Weinberg model its clinical value. For autosomal recessive diseases, the carrier frequency tells you how many people in a population carry one copy of the disease allele but show no symptoms.

Worked Examples

Example 1: Classic Distribution (p = 0.7)

A population has allele frequency p = 0.7 (the A allele is at 70%). The recessive allele a is at q = 0.3. Under Hardy-Weinberg equilibrium, the expected genotype distribution is 49% AA, 42% Aa, and 9% aa.

Setup: allele frequency mode, p = 0.7, N = 1000.

Result: AA = 490 (49%), Aa = 420 (42%), aa = 90 (9%).

Interpretation: This is the textbook distribution used as a baseline in introductory genetics. In a population of 1000 individuals, you would expect 490 homozygous dominant, 420 heterozygous, and 90 homozygous recessive.

Example 2: Balanced Population (p = 0.5)

When p = q = 0.5, the Hardy-Weinberg equation predicts p squared = 0.25, 2pq = 0.5, and q squared = 0.25. Heterozygotes are the most common genotype, at 50% of the population.

Setup: allele frequency mode, p = 0.5, N = 1000.

Result: AA = 250 (25%), Aa = 500 (50%), aa = 250 (25%).

Interpretation: This is the maximum-frequency distribution. When both alleles are at 50%, heterozygotes outnumber either homozygote because 2pq is bounded by 1 in the middle.

Example 3: PKU Carrier Frequency

Phenylketonuria (PKU) is an autosomal recessive disease. In some populations, the disease frequency (aa) is about 1 in 10,000. From q squared = 1/10000 we get q = 0.01 and p = 0.99. The carrier frequency (Aa) under Hardy-Weinberg is 2pq = 0.0198, about 1 in 50.

Setup: allele frequency mode, p = 0.99, N = 10000.

Result: AA = 9801 (98.01%), Aa = 198 (1.98%), aa = 1 (0.01%).

Interpretation: Even though PKU is rare (1 per 10000 affected), about 1 in 50 people is a heterozygous carrier. This is why two apparently unaffected parents can have an affected child: both are carriers.

Example 4: Sickle Cell Trait (Balanced Polymorphism)

In regions with historical malaria, the sickle cell allele is maintained at relatively high frequency because heterozygotes have a malaria survival advantage. In some sub-Saharan African populations, q is around 0.1, so p = 0.9.

Setup: allele frequency mode, p = 0.9, N = 1000.

Result: AA = 810 (81%), Aa = 180 (18%), aa = 10 (1%).

Interpretation: The heterozygote frequency (18%) is high. The aa frequency (1%) corresponds to actual sickle cell disease, which is rarer than the trait. This is a classic example of balanced polymorphism.

Example 5: Real Population Counts

A student samples 200 individuals and counts 60 AA, 90 Aa, 50 aa. They want to estimate the underlying allele frequencies. The Hardy-Weinberg calculator derives p = (2 times 60 + 90) / 400 = 0.525 and q = 1 – 0.525 = 0.475.

Setup: observed counts mode, AA = 60, Aa = 90, aa = 50.

Result: p = 0.525, q = 0.475, expected AA = 55.13, expected Aa = 99.75, expected aa = 45.13.

Interpretation: The observed counts (60, 90, 50) are close to the expected counts (55.13, 99.75, 45.13). This sample appears consistent with Hardy-Weinberg equilibrium. A chi-square test confirms the fit formally.

Hardy-Weinberg Assumptions

The Hardy-Weinberg equilibrium holds only when a population meets five assumptions. If any one fails, the model breaks and the expected genotype frequencies no longer match real-world counts:

  • No selection: all genotypes have equal survival and reproduction.
  • Random mating: individuals pair without preference for genotype.
  • No mutation: alleles do not change from A to a or vice versa.
  • No migration: no individuals enter or leave the population.
  • Infinite population size: genetic drift does not change allele frequencies.

Real populations always violate at least one of these assumptions. The Hardy-Weinberg biology calculator is most useful as a null model: a baseline prediction that lets you detect when something interesting is happening.

Who Were Hardy and Weinberg?

The Hardy-Weinberg principle is named after two independent discoverers working in different countries at the same time. They arrived at the same result in 1908 without knowing about each other, which is one reason the principle carries both names today.

Godfrey Harold Hardy (1877 to 1947)

Godfrey Harold Hardy

1877 to 1947
English mathematician

G. H. Hardy was an English mathematician, born February 7, 1877 in Cranleigh, Surrey, and died December 9, 1947 in Cambridge. He is best known for his work in pure mathematics, especially number theory, where his long collaboration with Srinivasa Ramanujan produced some of the deepest results of twentieth century mathematics. Hardy held the Savilian Chair of Geometry at Oxford from 1919 to 1931, then moved to Cambridge as Sadleirian Professor of Pure Mathematics from 1931 to 1942.

Hardy’s contribution to genetics came almost by accident. According to a story widely repeated in genetics textbooks, the question of whether Mendelian ratios would stay stable under random mating came up at a dinner party. Hardy reportedly regarded the problem as trivial and wrote up the answer in a short letter to the editor of Science magazine, published July 10, 1908 under the title “Mendelian Proportions in a Mixed Population.” The letter was only two pages long. Hardy himself considered it one of his lesser contributions and was reportedly amused that it outlived much of his serious mathematical work in public memory.

Wilhelm Weinberg (1862 to 1937)

Wilhelm Weinberg

1862 to 1937
German physician and population geneticist

Wilhelm Weinberg was a German physician, born February 13, 1862 in Stuttgart, and died November 27, 1937 in Tübingen. He practiced general medicine in Stuttgart for most of his career and pursued statistical genetics as a side interest alongside his medical work. He also contributed methods for twin studies and population comparisons that are still used in epidemiology.

Weinberg independently derived the same equilibrium result as Hardy, publishing in 1908 in the Jahreshefte des Vereins für vaterländische Naturkunde in Württemberg, a German regional natural history journal. Because his paper was in German and in a less widely read journal, it received much less attention than Hardy’s Science letter at the time. The dual “Hardy-Weinberg” naming came later, once population geneticists recognized that both scientists deserved credit for the same discovery.

Why Both Names?

The dual naming reflects a pattern in population genetics history. Several independent thinkers had worked out parts of the equilibrium idea. W. E. Castle noted the stability of Mendelian populations in 1903, and Reginald Punnett (who prompted Hardy’s contribution) discussed the question in his own 1905 textbook.

Weinberg, Hardy, and the others all converged on the same insight within a few years of each other. Pairing their names acknowledges that the principle was not the work of one mind but the convergence of several.

The principle itself, of course, predates everyone. The math is older than any of its discoverers. What Hardy and Weinberg contributed was the demonstration that, given certain assumptions, allele frequencies and genotype frequencies settle into a predictable equilibrium in a single generation and then stay there.

That theorem is the foundation of nearly every population genetics analysis done today, including every calculation in this calculator.

Hardy-Weinberg vs Punnett Square

A Punnett square calculator predicts the offspring of one mating pair. The Hardy-Weinberg equilibrium calculator predicts the genotype distribution across an entire population at equilibrium. They are different tools for different questions, but they share the underlying p and q logic.

For population genetics problems (estimating allele frequencies, predicting carrier rates, testing for selection), use the Hardy-Weinberg calculator. For single-family inheritance problems (predicting a child’s genotype from two parents), use a Punnett square calculator. For verifying whether observed data matches the equilibrium prediction, run a chi-square test.

Limits of the Hardy-Weinberg Model

  • Two alleles only: this calculator handles the classic two-allele case. Genes with three or more alleles (like ABO blood type) need a multi-allele extension.
  • Autosomal inheritance only: X-linked and Y-linked genes have different equilibrium equations because allele frequencies differ between sexes.
  • One locus at a time: the model treats each gene independently. Linkage disequilibrium between genes is not modeled.
  • Diagnostic, not predictive: the model tells you whether a population is in equilibrium. It does not tell you which evolutionary force is responsible for any deviation.

Related Resources

Frequently Asked Questions

What is a Hardy-Weinberg calculator?

A Hardy-Weinberg calculator is a population genetics tool that applies the Hardy-Weinberg principle to allele and genotype frequencies. It can predict genotype frequencies from allele frequencies, or derive allele frequencies from observed genotype counts in a sample.

What does the Hardy-Weinberg equation predict?

The Hardy-Weinberg equation p squared plus 2pq plus q squared = 1 predicts the genotype frequencies in any population at equilibrium, given the allele frequencies p and q. The three terms correspond to homozygous dominant (p squared), heterozygous (2pq), and homozygous recessive (q squared) individuals.

How do I calculate allele frequencies from observed counts?

To calculate allele frequencies from observed counts of AA, Aa, and aa individuals, use the formulas p = (2 times AA + Aa) / (2 times N) and q = 1 – p, where N is the total number of individuals. The Hardy-Weinberg calculator does this automatically when you switch to observed counts mode.

What is the carrier frequency in a population?

The carrier frequency is the proportion of heterozygous individuals (Aa) in a population. For autosomal recessive diseases, it equals 2pq where p is the dominant allele frequency and q is the recessive allele frequency. For PKU in some populations it is about 1 in 50. For cystic fibrosis in European populations it is about 1 in 25.

How does the Hardy-Weinberg principle relate to evolution?

The Hardy-Weinberg principle provides a null model. Real populations always deviate from it because at least one assumption (no selection, random mating, no mutation, no migration, infinite size) is violated. Detecting the deviation is the first step in identifying which evolutionary force is at work in a population.

Can I use the Hardy-Weinberg calculator for X-linked genes?

No. The standard Hardy-Weinberg model assumes autosomal inheritance. X-linked genes have different equilibrium equations because allele frequencies differ between males and females (males have only one X chromosome, so they cannot be heterozygous for X-linked traits). Use a specialized X-linked inheritance calculator for those cases.

What does it mean if observed does not match expected?

If observed genotype counts deviate from the expected Hardy-Weinberg counts, something is acting on the population. Common causes include natural selection, non-random mating, recent migration, small population size (genetic drift), or mutation. A chi-square goodness of fit test confirms whether the deviation is statistically significant.

About the Hardy-Weinberg Calculator

The Hardy-Weinberg Calculator is part of the BioExplorer suite of free population genetics learning tools. It is designed for students working through introductory or college genetics, AP Biology, or population biology courses, and for teachers preparing example problems.

The calculator implements the classic two-allele Hardy-Weinberg equation for both directions: from allele frequency to expected genotype counts, and from observed counts back to allele frequencies. It supports any sample size from 1 to millions of individuals, and the visual equilibrium check helps users detect when a population deviates from the predicted distribution. For formal verification, run the separate chi-square test calculator.

Last updated: July 3, 2026

Cite this page

Bio Explorer. (2026, July 3). Hardy-Weinberg Calculator. https://www.bioexplorer.net/hardy-weinberg-calculator/