Hardy–Weinberg & Genetic Drift Tool
Free Hardy-Weinberg calculator: find allele and carrier frequencies, run a χ² equilibrium test, and simulate genetic drift with step-by-step working.
Hardy–Weinberg & Genetic Drift Tool
Enter the observed number of individuals of each genotype to test whether the population is in Hardy–Weinberg equilibrium.
Simulate random changes in allele frequency (genetic drift) in several small populations at once.
Quick start
- On the Calculator tab, choose a mode: Frequencies, χ² Test or Drift Simulator.
- Fill in the boxes.
- Press Calculate (or press
Enterin any box). - Read the result, then open Show working to see each step. Use Copy result to paste the answer into your notes.
Mode 1: Frequencies
Finds all the allele and genotype frequencies from one known value.
- Choose what you know: q² (the recessive phenotype, the most common case), q, p, or p².
- Enter the value as a decimal (0.0004) or switch the format to percent (0.04).
- Optionally enter a population size to see the expected number of people of each genotype.
The tool gives q = 0.02, p = 0.98 and a carrier frequency 2pq ≈ 0.0392, or about 1 carrier in 26 people.
Mode 2: χ² Test
Checks whether real genotype counts match Hardy–Weinberg expectations.
- Enter the observed numbers of AA, Aa and aa individuals (whole numbers).
- The tool estimates p and q from your data, works out the expected counts, and calculates χ² with 1 degree of freedom.
- A p-value of 0.05 or more means the population is consistent with equilibrium. Below 0.05 means it differs significantly.
χ² ≈ 0.22 and p ≈ 0.64, so the population is consistent with Hardy–Weinberg equilibrium.
Mode 3: Drift Simulator
Shows how allele frequencies wander at random in finite populations.
- Set the starting frequency of allele A, the population size, how many generations to run, and how many separate populations to simulate.
- Each coloured line on the graph is one population. The dashed grey line is the starting frequency.
- The summary counts how many populations fixed A (p = 1), lost it (p = 0), or still have both alleles.
Every run is random, so press Calculate again for a new result.
Extra options
- Significant figures: changes how many figures are shown in answers.
- Live update: recalculates as you type (Frequencies and χ² Test only).
- Reset: clears or restores the boxes in the current mode.
- Recent calculations: your last six answers are listed under the result until you refresh the page.
Troubleshooting
- “The value must be between 0 and 1”: frequencies can't be negative or above 1. If you typed a percentage, switch the format to Percent.
- “Only one allele is present”: if p or q is 0 there is nothing to test.
- Small-sample warning: if any expected count is below 5, the χ² result may not be reliable.
The Hardy–Weinberg principle
In a large population with random mating and no other evolutionary forces, allele and genotype frequencies stay the same from one generation to the next. For a gene with two alleles, A (dominant) and a (recessive):
- \(p\) = frequency of allele A
- \(q\) = frequency of allele a
- \(p^2\) = frequency of AA
- \(2pq\) = frequency of Aa (carriers)
- \(q^2\) = frequency of aa
The five assumptions
- No mutation
- Random mating
- No gene flow (no migration in or out)
- A very large population (no genetic drift)
- No natural selection
No real population meets all five perfectly. That is why the principle is so useful: if the genotype counts don't match the predictions, at least one assumption is being broken, which is a clue that evolution is happening.
Finding carrier frequency
Only people with the recessive phenotype (aa) can be identified directly, so we start from q² and work backwards:
Carriers are far more common than the disease itself. If 1 in 2500 people are affected (q² = 0.0004), then q = 0.02 and about 1 in 26 people carry the allele.
The chi-square test
To test for equilibrium, estimate p from the observed genotypes, calculate the expected counts, and compare:
There are 3 genotype classes, minus 1, minus 1 more for the allele frequency estimated from the data, so there is 1 degree of freedom. The critical value at the 5% level is 3.841. A larger χ² (smaller p-value) means the data differ significantly from the Hardy–Weinberg expectation. The test works best when every expected count is at least 5.
Genetic drift
In a finite population, the alleles that make it into the next generation are a random sample of the parents' alleles. Each generation, allele frequency therefore changes by chance, with no help from selection. Drift is much stronger in small populations, and over time it can eliminate an allele or make it the only one present (fixation). Drift also steadily reduces heterozygosity:
Here H = 2pq, N is the number of individuals and t is the number of generations. The founder effect and population bottlenecks are real-world examples, where a small group starts or survives as a population and carries only a sample of the original gene pool.
The simulator uses a simple model: constant population size, random mating, and no selection, mutation or migration.
Common mistakes
- Treating the frequency of the disease (q²) as the frequency of the allele (q). You must take the square root.
- Forgetting that carriers are 2pq, not q.
- Using percentages in the formulas without converting them to decimals.
- Using the Hardy–Weinberg equations for genes with more than two alleles, or for sex-linked genes, without adjusting them.
