Population Genetics Explorer
Track a single locus through hundreds of generations under any combination of selection, mutation, drift, and migration. The simulation applies all four forces every generation and renders the resulting allele frequency trajectory, a de Finetti genotype triangle, and a Hardy-Weinberg chi-square check on the starting frequencies.
Allele frequency p over time
Genotype frequency triangle (de Finetti)
Results
Compares observed AA, Aa, aa from your starting p with the random mating expectation (using p estimated from those counts as if it were a sample of N = 100).
| Genotype | Observed | Expected |
|---|---|---|
| AA | 25.00 | 25.00 |
| Aa | 50.00 | 50.00 |
| aa | 25.00 | 25.00 |
Selection (relative fitness)
Mutation rates
Migration
Selection step
With genotype fitnesses w(AA), w(Aa), w(aa), allele A frequency after one round of viability selection is
Mutation step
Forward mutation rate μ (A → a) and backward rate ν (a → A) give
Migration step
Each generation a fraction m of the population is replaced by migrants whose allele A frequency is p_source.
Drift step
For finite N, the next generation samples 2N alleles binomially:
With N set to Infinite, drift is skipped and trajectories are deterministic.
Reference Guide
The five Hardy-Weinberg assumptions
A locus stays at p², 2pq, q² genotype frequencies generation after generation only when all five conditions hold.
- No selection. All genotypes have equal viability and fertility.
- No mutation. Allele identities are inherited unchanged.
- No migration. The population is closed to gene flow.
- Random mating. Mate choice is independent of genotype at this locus.
- Infinite population size. Allele frequencies are not jostled by sampling.
When any one condition fails, allele frequencies drift away from their starting values. This tool lets you turn each violation on and watch the result.
Evolutionary forces
Each generation the simulator applies forces in this order.
Fitness, viability, and selection patterns
The fitness sliders set relative survival and reproduction of each genotype. The form of selection determines the long-term outcome.
- Directional. w(AA) > w(Aa) > w(aa) drives p toward 1.
- Stabilizing or overdominance. w(Aa) larger than both homozygotes maintains a polymorphism at intermediate p.
- Underdominance. w(Aa) smaller than both homozygotes pushes p toward whichever boundary it starts closer to and erases variation.
- Frequency-independent. Fitness values here do not depend on p, only on genotype.
A small fitness difference of 0.01 still moves p substantially over 200 generations when the population is large.
When drift dominates selection
The variance in p from one generation of drift is approximately . Selection coefficient s competes with drift through the product 2Ns.
- 2Ns much greater than 1. Selection wins. Trajectories are nearly deterministic.
- 2Ns near 1. Selection and drift are comparable. Outcomes vary across replicates.
- 2Ns much less than 1. Drift wins. Alleles fix or are lost roughly at random.
Run the 10-replicates button with a small N (around 20 to 50) and equal fitnesses to see drift fix or lose alleles purely by chance.