Skip to content

Unit 7 ยท Natural selection

Natural selection & Hardy-Weinberg

A population of peppered moths: dark moths carry at least one dominant allele (A), light moths are homozygous recessive (aa). Set the starting frequencies, apply selection pressure, and advance generations to watch the population's coloring shift.

Population setup

p = frequency of allele A (dark), q = frequency of allele a (light). p + q always equals 1.

Run the population forward

Generation 0

Every icon below is one moth in the population, sized to match the actual genotype frequencies.

p โ€” dominant allele
0.600
q โ€” recessive allele
0.400
Gene pool60% A ยท 40% a
AA + Aa (dark)40 moths
aa (light)8 moths
๐Ÿ’ก Selection is acting: Light (aa) moths are more visible to predators against dark bark, so q falls each generation โ€” fast at first, then slower as aa moths become rare and harder to select against further.

Allele frequency across generations

Every earlier panel only shows the current generation โ€” this is the trend that produced it.

0.000.250.500.751.00Generationp (A)q (a)

The five conditions for Hardy-Weinberg equilibrium

A population only stays in equilibrium if all five hold. This simulation only breaks one of them on purpose.

  • No mutation โ€” allele forms aren't being created or lost.
  • Random mating โ€” no preference for particular genotypes.
  • No gene flow โ€” no individuals migrating in or out.
  • Very large population โ€” no random drift from small sample sizes.
  • No natural selection โ€” every genotype survives and reproduces equally (this is the one the slider above breaks).