Hardy-Weinberg Equilibrium: Population Genetics Simulator

simulator intermediate ~12 min
Loading simulation...
Equilibrium — p² = 0.25, 2pq = 0.50, q² = 0.25

With equal allele frequencies (p = q = 0.5) and no evolutionary forces, the population remains in Hardy-Weinberg equilibrium: 25% AA, 50% Aa, 25% aa — indefinitely stable.

Formula

p² + 2pq + q² = 1 (Hardy-Weinberg genotype frequencies)
Δp = −spq² / (1 − sq²) (change in allele frequency under selection)

The Null Model of Evolution

In 1908, mathematician G. H. Hardy and physician Wilhelm Weinberg independently proved that allele frequencies in a population do not change from generation to generation — provided certain idealizing conditions hold. This Hardy-Weinberg principle is the fundamental null hypothesis of population genetics. Any observed change in allele frequencies over time implies that one or more evolutionary forces are at work.

The Hardy-Weinberg Equation

For a gene with two alleles A (frequency p) and a (frequency q = 1−p), the expected genotype frequencies are: AA = p², Aa = 2pq, aa = q². These frequencies emerge after a single generation of random mating and remain constant forever — unless disturbed by selection, drift, mutation, migration, or non-random mating. This simulation plots these frequencies over generations so you can watch equilibrium hold or break.

Genetic Drift in Small Populations

Real populations are finite, and random sampling introduces noise into allele transmission. In a population of 50 individuals, allele frequencies can swing wildly from generation to generation — this is genetic drift. Try reducing population size in the simulation and watch how p fluctuates. In extreme cases, one allele may be lost entirely (fixation of the other). This is why small populations lose genetic diversity and become vulnerable to extinction.

Selection Against the Recessive

When the selection coefficient s > 0, individuals with genotype aa have reduced fitness (1 − s). Over generations, the frequency of allele a declines — but not linearly. The rate of decline slows dramatically as a becomes rare, because most remaining copies are hidden in Aa heterozygous carriers who suffer no fitness cost. This is why harmful recessive diseases persist in human populations at low frequencies, even under persistent selection.

FAQ

What is the Hardy-Weinberg principle?

The Hardy-Weinberg principle states that in an idealized population (infinite size, no selection, no mutation, no migration, random mating), allele and genotype frequencies remain constant from generation to generation. It serves as the null hypothesis of population genetics — any deviation implies evolution is occurring.

What causes deviations from Hardy-Weinberg equilibrium?

Five main forces cause deviation: natural selection (differential fitness), genetic drift (random sampling in finite populations), mutation (new alleles), migration (gene flow between populations), and non-random mating (assortative mating or inbreeding). Real populations always experience some combination of these forces.

What is genetic drift?

Genetic drift is the random change in allele frequencies due to chance sampling in finite populations. It is stronger in small populations and can lead to the fixation (frequency = 1) or loss (frequency = 0) of alleles regardless of their fitness effects. It is the reason endangered species lose genetic diversity.

How does natural selection change allele frequencies?

Selection changes allele frequencies by giving organisms with certain genotypes higher survival or reproductive success. If aa individuals have lower fitness (selection coefficient s > 0), the frequency of allele a decreases each generation. However, recessive alleles are sheltered in heterozygous carriers, slowing their elimination.

Sources

Embed

<iframe src="https://homo-deus.com/lab/genetics/hardy-weinberg/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub