Skip to content

Hardy-Weinberg Calculator

Calculate allele and genotype frequencies under Hardy–Weinberg equilibrium from genotype counts or the recessive trait, test equilibrium with χ², or work out ABO frequencies.

Calculator Details

Allele frequencies:p = 0.6, q = 0.4See results ↓

Genotype counts, the frequency of the recessive trait, or three allele frequencies (ABO)

Number of individuals with genotype AA

Number with genotype Aa

Number with genotype aa

Your Results

Allele frequencies: p = 0.6, q = 0.4

Allele frequencies

p = 0.6, q = 0.4

From 1,000 individuals

Heterozygotes (carriers) 2pq

48%

About 1 in 2.08

χ² equilibrium test (1 df)

χ² = 0

p-value 1: no evidence against equilibrium at the 5% level

Observed heterozygosity

48%

Expected 48%

The allele frequencies are p = 0.6 and q = 0.4, so about 48% of the population are heterozygous carriers (1 in 2.08). χ² = 0 (p = 1): consistent with Hardy–Weinberg equilibrium at the 5% level.

Compare scenarios

Save these inputs as a scenario, change them, and compare the results side by side.

Loading, available in a moment

Observed and expected genotype counts

Observed and expected genotype counts

Detailed Breakdown

Genotypes under Hardy–Weinberg equilibrium
GenotypeFrequencyObservedExpectedχ² part
AA (p²)0.363603600
Aa (2pq)0.484804800
aa (q²)0.161601600

How This Calculator Works

How It’s Calculated

p + q = 1 · p² + 2pq + q² = 1
From counts: p = (2·AA + Aa) ÷ 2N · From the trait: q = √(aa)
χ² = Σ (O − E)² ÷ E, 1 degree of freedom

Your calculation: p = (2 × 360 + 480) ÷ (2 × 1000) = 0.6, q = 0.4. Expected heterozygotes 2pq × N = 480 against 480 observed; χ² = 0.

The equilibrium assumes a large, randomly mating population with no selection, mutation, migration or genetic drift. Real populations are an approximation, so read the results as estimates for a population, not for any one person.

Frequently Asked Questions

What is the Hardy–Weinberg equation?

For a gene with two alleles at frequencies p and q (p + q = 1), a randomly mating population settles at genotype frequencies p² (AA), 2pq (Aa) and q² (aa), which add to 1. The allele frequencies then stay the same from one generation to the next as long as nothing changes them.

How do I find allele frequencies from genotype counts?

Count alleles, not people. Each AA individual carries two A alleles and each Aa carries one, so p = (2·AA + Aa) ÷ 2N, where N is the number of individuals, and q = 1 − p. With 360 AA, 480 Aa and 160 aa, p = 1,200 ÷ 2,000 = 0.6.

How do I find q from the number of people with a recessive trait?

Only aa individuals show a recessive trait, so their frequency is q², and q is its square root. If 1 person in 2,500 (0.04%) has the trait, q = 0.02 and p = 0.98. This works only if the population is in equilibrium for that gene.

Why are carriers so much more common than people with the trait?

When q is small, 2pq is much larger than q². For a trait in 1 of 2,500 people, about 3.92% of people, roughly 1 in 25.5, carry one copy without showing it. Most copies of a rare recessive allele are hidden in heterozygotes. If the trait were common, say 16%, carriers would be 48%.

How do I test whether a population is in Hardy–Weinberg equilibrium?

Compare the observed genotype counts with the p²N, 2pqN and q²N expected from the allele frequencies, using a χ² goodness-of-fit test with one degree of freedom. A sample of 50 AA, 20 Aa and 30 aa gives χ² = 34.03, far above the 3.84 needed at the 5% level: it has too few heterozygotes for equilibrium.

What can push a population out of equilibrium?

Natural selection, mutation, migration (gene flow), genetic drift in small populations, and non-random mating such as inbreeding or choosing similar mates. Inbreeding and population structure typically show up as a shortage of heterozygotes; selection against one genotype changes the frequencies over generations.

How does Hardy–Weinberg work with three alleles like ABO?

With allele frequencies p (Iᴬ), q (Iᴮ) and r (i), the genotype frequencies are the terms of (p + q + r)². Because Iᴬ and Iᴮ are dominant to i, group A is p² + 2pr, group B q² + 2qr, AB 2pq and O r². With p = 0.3, q = 0.1 and r = 0.6, that is 45% A, 13% B, 6% AB and 36% O.

Can this tell me my own chance of carrying a gene?

No. Hardy–Weinberg describes averages in a large population. A person’s chance depends on their family history and ancestry, and genetic testing and counselling are the way to answer that. The calculator is for learning and population-level estimates.

Uses the Hardy–Weinberg principle (Hardy 1908, Weinberg 1908) for one gene with two alleles, or three alleles with the ABO dominance pattern, and the 1-degree-of-freedom χ² goodness-of-fit test (Emigh 1980). It assumes a large, randomly mating population without selection, mutation, migration or drift. It leaves out exact tests for small samples, sex-linked genes, more than three alleles and linkage between genes. It describes populations for learning and research and is not a genetic risk assessment for any person.

Hardy-Weinberg Calculator: Allele and Genotype Frequencies with a χ² Test

By FindMySum · Last reviewed

The Hardy–Weinberg principle is the baseline of population genetics: in a large population where nothing is changing allele frequencies, genotype frequencies settle at predictable proportions and stay there. This Hardy–Weinberg calculator works out allele frequencies from genotype counts and tests whether those counts fit equilibrium, estimates allele and carrier frequencies from how common a recessive trait is, and extends the principle to three alleles for the ABO blood groups.

The equations

For one gene with two alleles, A at frequency p and a at frequency q:

  • p + q = 1
  • p² + 2pq + q² = 1

The three terms are the expected frequencies of AA, Aa and aa. They follow from random mating: an individual gets A from each parent with probability p, so AA has probability p², aa has q², and Aa can arise two ways, giving 2pq.

From genotype counts

If you can tell all three genotypes apart, as with codominant blood groups or a DNA marker, count alleles:

  • p = (2 × AA + Aa) ÷ 2N
  • q = 1 − p

where N is the number of individuals. Multiply p², 2pq and q² by N to get the counts expected at equilibrium, then compare them with the observed counts.

Worked example: the default sample

The calculator opens with 360 AA, 480 Aa and 160 aa individuals, 1,000 in all.

  • p = (2 × 360 + 480) ÷ 2,000 = 1,200 ÷ 2,000 = 0.6, and q = 0.4
  • Expected AA = 0.6² × 1,000 = 360, expected Aa = 2 × 0.6 × 0.4 × 1,000 = 480, expected aa = 0.4² × 1,000 = 160

The observed and expected counts match exactly, so χ² = 0 and the sample sits in equilibrium. Change the counts to 50, 20 and 30 and p is still 0.6, but now there are far fewer heterozygotes than the 48 expected. χ² climbs to 34, with a p-value around 5 × 10⁻⁹: strong evidence the population is not mating at random, or that something such as inbreeding or population mixing is at work.

The χ² test for equilibrium

The test statistic is χ² = Σ (observed − expected)² ÷ expected over the three genotypes. It has one degree of freedom: three classes, minus one because the counts add to N, minus one more because p was estimated from the same data. A χ² above 3.84 means p < 0.05, the usual threshold for rejecting equilibrium. The table shows each genotype's contribution, so you can see which class drives a departure. When any expected count falls below 5 the approximation weakens, and the page says so.

From a recessive trait

Often only the recessive phenotype can be recognised, because AA and Aa look alike. Then q² is the share of people with the trait, and q = √q². If 1 person in 2,500 has a recessive trait, q² = 0.0004, q = 0.02 and p = 0.98. Carriers are 2pq = 3.92%, about 1 in 25.5. This shows why rare recessive conditions persist: about 98 copies of the allele out of every 100 sit in healthy carriers, where selection cannot act on them. The calculation assumes equilibrium, which cannot be checked from phenotype counts alone.

Three alleles: ABO blood groups

With three alleles the genotype frequencies are the terms of (p + q + r)²: p², q², r², 2pq, 2pr and 2qr. In the ABO system Iᴬ and Iᴮ are codominant with each other and both dominant to i, so:

  • Group A = p² + 2pr
  • Group B = q² + 2qr
  • Group AB = 2pq
  • Group O = r²

Enter p and q and the calculator sets r = 1 − p − q. With p = 0.3, q = 0.1 and r = 0.6, it predicts 45% group A, 13% B, 6% AB and 36% O. Working backwards from observed blood-group frequencies, r is √(O), a method first used by Felix Bernstein in 1924 to show that ABO is controlled by one gene with three alleles.

Assumptions and limits

Hardy–Weinberg proportions hold exactly only in an idealised population: very large, randomly mating, with no selection, no mutation, no migration and equal survival of all genotypes. Real populations break these assumptions to some degree, and the χ² test is one way to see how much. The calculator handles one autosomal gene at a time. It does not cover sex-linked genes, more than three alleles or linkage between genes, and it describes populations, not the genetic risk of any individual, which needs family history, testing and genetic counselling.

More questions

Who were Hardy and Weinberg?

G. H. Hardy was an English mathematician who published the principle in Science in 1908, partly to answer the mistaken idea that dominant alleles must spread until three quarters of a population show them. Wilhelm Weinberg, a German physician, derived the same result independently the same year. The principle is sometimes called the Hardy–Weinberg–Castle law after William Castle's 1903 work.

Does a dominant allele become more common over time?

Not on its own. Dominance only decides which phenotype a heterozygote shows; it does nothing to the allele frequencies. Without selection, mutation, migration or drift, a rare dominant allele stays rare and a common recessive one stays common. This was the point Hardy's paper made.

What is the difference between allele frequency and genotype frequency?

An allele frequency is the share of all copies of a gene in the population that are one version (p for A). A genotype frequency is the share of individuals with a particular pair (AA, Aa or aa). Each person carries two copies, so a population of 1,000 has 2,000 copies to count for the allele frequencies.

How many generations does it take to reach equilibrium?

For one autosomal gene, just one generation of random mating. Whatever the starting genotype mix, the offspring of a randomly mating population have p², 2pq and q² proportions. Genes on the X chromosome take several generations to converge because males and females carry different numbers of copies.

What sample size do I need for the χ² test?

The χ² approximation is reliable when every expected count is at least about 5. For rare alleles or small samples the expected number of homozygotes for the rare allele is often below that, and population geneticists use an exact test instead (Wigginton, Cutler and Abecasis, 2005). The calculator warns when an expected count is under 5.

Why do geneticists use Hardy–Weinberg tests on DNA data?

As a quality check. In large genotyping studies, a marker that departs strongly from equilibrium in healthy controls often points to a genotyping error, such as one allele failing to amplify, rather than to real biology. Markers that fail the test are commonly removed before analysis.

Sources

This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.

Spotted a wrong result or a bug? Report a problem

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy