This is a 2D companion to the "Balancing Selection: Heterozygote Advantage" 3D sim, built around genuinely different mechanics: instead of rendering a field of instanced spheres, it shows the two classic 2D tools population geneticists actually use to reason about overdominance — Wright's adaptive landscape (mean fitness w̄ as a function of allele frequency, with the population as a ball that selection rolls uphill) and the de Finetti triangle (genotype frequencies plotted directly in barycentric coordinates against the Hardy-Weinberg parabola).
Fitness: w_AA = 1-s1, w_Aa = 1, w_aa = 1-s2
Landscape: w̄(q) = 1 - s1·(1-q)² - s2·q² (peaks exactly at q*)
Selection: p' = (p²w_AA + pq·w_Aa) / w̄
Drift: next-gen allele count ~ Binomial(2N, p')
Equilibrium: q* = s1 / (s1 + s2) (d w̄/dq = 0 solved analytically)
The same discrete Wright-Fisher recursion drives all three panels, computed independently here: the landscape ball's horizontal position is the live allele frequency q, sitting on the analytically-exact w̄(q) curve; the triangle plots the population's actual genotype counts (AA, Aa, aa) as one point, so genetic drift shows up as scatter around — not exactly on — the theoretical Hardy-Weinberg parabola; and the q(t) chart runs 20 replicate populations in parallel with independent random draws to show how far genetic drift can push a finite population away from the deterministic curve.
- s₁, s₂ sliders — reshape the landscape: together they set where its peak (q*) sits and how sharply fitness falls off each side.
- Population size N — smaller N means noisier drift; the ball wobbles and the triangle point scatters further from the parabola.
- q₀ slider — starting allele frequency; the ball always starts uphill of q* unless it's already there.
- Deterministic overlay — the drift-free recursion run from the same q₀, for comparison against the noisy real trajectory.
- Drift spread — mean ± 1 s.d. across 20 independent replicate populations with the same s₁, s₂, N.
Real-world example: the sickle-cell allele (HbS) is maintained at ~10-15% frequency in malaria-endemic regions because heterozygotes (HbA/HbS) resist severe malaria while HbA/HbA is more malaria-susceptible and HbS/HbS causes sickle-cell disease — the textbook case of balancing selection in a human population.