Biology

Hardy-Weinberg Calculator

Solve the Hardy-Weinberg equation from an allele frequency, or estimate allele frequencies from genotype counts.

The Hardy-Weinberg equation, p² + 2pq + q² = 1, links allele frequencies to genotype frequencies in an idealized population. Start from a known allele frequency, or work backward from the numbers of each genotype you counted.

Start from

q = 1 − p

0.4

p² (homozygous dominant)

0.36

2pq (heterozygous)

0.48

q² (homozygous recessive)

0.16

Sum (should be 1)

1

How it works

The Hardy-Weinberg principle says that in a large, randomly mating population with no selection, migration, or mutation, allele frequencies stay put and genotype frequencies follow p² + 2pq + q² = 1.

Give it a single allele frequency p and it fills in q = 1 − p, then the three genotype frequencies p², 2pq, and q², and checks they add to 1 the way they should.

Switch to counts mode and enter how many of each genotype you observed. It counts alleles — two per individual — to estimate p and q, then shows the genotype numbers you'd expect if the population were in equilibrium.

Frequently asked questions

What do p and q actually represent?

p is the frequency of the dominant allele and q the frequency of the recessive one. Because there are only two alleles here, they always add up to 1.

How does it get allele frequencies from counts?

Every individual carries two alleles, so it counts 2 for each homozygote and 1 for each heterozygote, then divides by twice the total number of individuals to get p and q.

My expected counts don't match what I observed — why?

Real populations drift from equilibrium because of selection, small size, non-random mating, and chance. A gap between expected and observed is exactly what tells you those forces are at work.