Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Hardy-Weinberg & Natural Selection Lab

Investigate how allele frequencies change across generations under different evolutionary forces. Start with a population in Hardy-Weinberg equilibrium, then apply selection, drift, mutation, or migration to observe evolution in action.

Guided Experiment: Testing Hardy-Weinberg Equilibrium

If a population meets all five Hardy-Weinberg conditions (no selection, no drift, no mutation, no migration, random mating), what do you predict will happen to allele frequencies over 50 generations?

Write your hypothesis in the Lab Report panel, then click Next.

Controls

Results

Run the simulation to see results. Adjust parameters on the left and click Run.

Allele Frequency Over Generations

Run the simulation to see the allele frequency trajectory.

AP-level extension

Chi-Square Goodness-of-Fit Analyzer

Enter observed genotype counts. The analyzer estimates allele frequencies, computes expected counts under Hardy-Weinberg, runs a chi-square goodness-of-fit test with df = 1, and decides whether to reject the HW null hypothesis.

AP-style preset problems

Observed counts

Total individuals: 200
Estimated allele frequencies
p (A) = (2·AA + Aa) / (2N) = 0.5000
q (a) = 1 − p = 0.5000

Expected vs observed

GenotypeObserved (O)Expected (E)(O − E)² / E
AA4950.000.020
Aa102100.000.040
aa4950.000.020
Total200200.00χ² = 0.080
Decision (α = 0.05)
Fail to reject H₀ — consistent with HWE
χ² statistic 0.080
Critical χ² (df=1, α=0.05) 3.841
p-value 0.7773
Decision rule χ² χ²crit
AP-level interpretation:

Because χ² does not exceed the critical value, we fail to reject the null hypothesis. The observed genotype frequencies are consistent with Hardy-Weinberg equilibrium given the estimated allele frequencies — but this does not prove HWE holds, only that the data are not inconsistent with it.

Degrees of freedom = 3 genotype classes − 1 estimated parameter (p) − 1 constraint (counts sum to N) = 1.

Data Table

(0 rows)
#TrialGenerationp (A)q (a)Freq AAFreq AaFreq aaChi-SquareIn Equilibrium?
0 / 500
0 / 500
0 / 500

Reference Guide

Hardy-Weinberg Principle

In a non-evolving population, allele and genotype frequencies remain constant across generations.

p+q=1p + q = 1
p2+2pq+q2=1p^2 + 2pq + q^2 = 1

Where p is the frequency of the dominant allele (A) and q is the frequency of the recessive allele (a).

Conditions for Equilibrium

Five conditions must hold for a population to stay in Hardy-Weinberg equilibrium.

  • No natural selection (all genotypes equally fit)
  • No genetic drift (infinitely large population)
  • No mutation (alleles do not change)
  • No migration (no gene flow in or out)
  • Random mating (no sexual selection)

Violating any condition causes allele frequencies to change, which means evolution is occurring.

Chi-Square Test

The chi-square goodness-of-fit test determines whether observed genotype frequencies match HW expectations.

χ2=(OiEi)2Ei\chi^2 = \sum \frac{(O_i - E_i)^2}{E_i}

With df = 1. If the p-value is greater than 0.05, the population is consistent with Hardy-Weinberg equilibrium.

Evolutionary Forces

Natural Selection favors alleles that increase fitness. Genotypes with higher w contribute more offspring.

Genetic Drift causes random changes in allele frequencies, especially in small populations.

Mutation introduces new alleles or converts existing ones, slowly shifting frequencies.

Migration (gene flow) brings alleles from other populations, moving frequencies toward the migrant pool.

Related Content