All topics
Intermediate

Population genetics · when nothing is changing

Hardy–Weinberg Calculator

Feed in one allele frequency and get the genotype frequencies a large, non-evolving population should show, or work backwards from real counts to the allele frequencies. It is the null hypothesis against which evolution is measured.

Click to begin

Explained like you're twelve. Explained like you've just finished school. Explained like you're at university.

By . Last updated .

Population genetics · Hardy & Weinberg, 1908

What the genotypes should look like when nothing is pushing them.

Hardy–Weinberg calculator

With two alleles at frequencies \(p\) and \(q = 1-p\), the genotype frequencies at equilibrium are \(p^2\) (AA), \(2pq\) (Aa) and \(q^2\) (aa), and they always sum to 1.

Hardy–Weinberg is a bookkeeping identity: square the allele frequencies and the genotype proportions follow. Its power is as a baseline. A population that is large, randomly mating, and free of mutation, migration and selection sits exactly here, so any real departure from these numbers is a fingerprint of one of those forces at work.

What is the Hardy–Weinberg principle?

In a population, a gene comes in different versions called alleles. Some individuals carry two copies of one version, some two of another, and some one of each. Population genetics asks a simple question: if you leave a population completely alone, how do those combinations shake out?

The Hardy–Weinberg principle is the answer. It says that if nothing is disturbing the population, no natural selection, no mutation, no one moving in or out, and mating is random, then the proportions of each genotype stay fixed forever and are set entirely by how common each allele is.

Say the more common allele makes up 60% of all copies and the other 40%. Then the fraction of individuals with two of the first is 0.6 × 0.6 = 36%, two of the second is 0.4 × 0.4 = 16%, and one of each is the rest, 48%. The calculator above does this for any allele frequency, and can also run it backwards from real counts.

The point is not that real populations sit still like this. It is that they mostly do not. Hardy–Weinberg is the "nothing is happening" baseline, and when a real population's numbers do not match, that mismatch is the clue that evolution, or something like it, is going on.

How do you use the Hardy–Weinberg equation?

Take a gene with two alleles. Let \(p\) be the frequency of one and \(q\) the frequency of the other, so that \(p + q = 1\). If mating is random, an individual gets one allele from each parent independently, so the chance of any genotype is the product of the allele frequencies.

That gives the Hardy–Weinberg genotype frequencies:

\[ p^2 + 2pq + q^2 = 1, \]

where \(p^2\) is the fraction of homozygous dominant (AA), \(q^2\) the homozygous recessive (aa), and \(2pq\) the heterozygotes (Aa). The \(2\) is there because a heterozygote can be formed two ways round, A from mum and a from dad or the reverse.

This is genuinely useful because recessive homozygotes are the one genotype you can often count directly, since they are the only ones showing the recessive trait. If 1 in 10,000 people has a recessive condition, then \(q^2 = 0.0001\), so \(q = 0.01\), \(p = 0.99\), and the carrier frequency \(2pq \approx 0.0198\), about 1 in 50. Roughly two hundred times as many people carry the allele as show the trait.

Run it the other way and the calculator becomes a test. Count the three genotypes in a real sample, work out the allele frequencies from them, and compare the genotype numbers you observed with the \(p^2, 2pq, q^2\) you would expect. A close match means the population is behaving as if undisturbed; a clear mismatch means one of the assumptions is broken.

Assumptions and tests for Hardy–Weinberg equilibrium

The equilibrium is reached in one generation

The striking feature of Hardy–Weinberg is that a randomly mating population reaches the \(p^2 : 2pq : q^2\) proportions after a single generation, whatever the starting genotype frequencies, and then stays there. Allele frequencies \(p\) and \(q\) are conserved by Mendelian segregation, and random union of gametes maps them to the genotype frequencies immediately. The equilibrium is a fixed point, not a slow approach.

The assumptions, and what breaks each one

The result rests on five idealisations: an infinitely large population (no genetic drift), random mating (no assortative mating or inbreeding), and no mutation, migration or selection. Each violation leaves a distinct signature. Selection and drift change the allele frequencies themselves; inbreeding leaves \(p\) and \(q\) alone but inflates the homozygotes at the expense of heterozygotes; migration mixes in outside allele frequencies. Sex-linked genes and multiple alleles have their own multinomial versions of the same identity.

Testing for equilibrium

A goodness-of-fit chi-square test compares observed genotype counts with the expected \(Np^2, 2Npq, Nq^2\), where the expected values use \(p\) estimated from the sample. With three genotype classes and one estimated parameter, the test has one degree of freedom, so a chi-square above about 3.84 rejects equilibrium at the 5% level. The calculator reports this comparison in counts mode.

Why the null hypothesis matters

Hardy–Weinberg is to population genetics what an object at rest is to mechanics: the state that persists when no force acts. Its real value is as a reference. Deviations are used to detect selection at specific loci, to estimate inbreeding coefficients, to flag genotyping errors in large datasets, and to infer carrier frequencies in medical genetics. The interesting biology lives in the departures from it, which is why the baseline has to be exact.

Related: Natural Selection · Punnett Squares · or go back to all topics.