Hardy-Weinberg Calculator

Testing Whether a Population Is Actually in Equilibrium

The Hardy-Weinberg principle describes the genotype ratios a population should settle into when no evolutionary forces — selection, mutation, migration, non-random mating, or drift — are acting on a gene. It's less useful as a prediction than as a null hypothesis: comparing a real population's observed genotype counts against the equilibrium expectation reveals whether one of those forces is actually at work. This calculator runs both directions of the analysis.

The Formula

p² + 2pq + q² = 1
Expected AA = p² × Total, Expected Aa = 2pq × Total, Expected aa = q² × Total
Χ² = Σ ((Observed − Expected)² ÷ Expected)

The chi-square statistic sums the squared, normalized deviation between observed and expected counts across all three genotype classes. With one degree of freedom (three genotype classes minus the allele frequency estimated from the data, minus one), the standard critical value at the 0.05 significance level is 3.841.

Worked Example: Genotype Frequencies From p

Given an allele frequency of p = 0.6:

Expected genotype frequencies at Hardy-Weinberg equilibrium, p = 0.6
GenotypeFormulaFrequency
AA36.00%
Aa2pq48.00%
aa16.00%

Worked Example: Testing Observed Counts

A sample of 100 individuals observed as 40 AA, 40 Aa, 20 aa (p = 0.6, q = 0.4): expected counts are 36 AA, 48 Aa, 16 aa. Χ² = (40−36)²/36 + (40−48)²/48 + (20−16)²/16 = 0.444 + 1.333 + 1.000 = 2.778. Since 2.778 is below the 3.841 critical value, this sample does not show a statistically significant departure from equilibrium.

Where This Matters

  • Detecting selection or non-random mating — a population significantly out of equilibrium points to an active evolutionary force worth investigating.
  • Validating genotyping data — in medical and agricultural genetics, a locus wildly out of Hardy-Weinberg equilibrium in a supposedly random-mating sample can flag a genotyping error rather than real biology.
  • Coursework and problem sets — the standard exercise for connecting allele frequencies to expected genotype distributions.

How to Use This Calculator

  1. Choose a mode: "Genotype Frequencies from Allele Frequency" or "Test Genotype Counts for HW Equilibrium".
  2. For the frequency mode, enter the allele frequency p (between 0 and 1).
  3. For the equilibrium test, enter observed AA, Aa, and aa genotype counts.
  4. Select Calculate to see the resulting frequencies, or the chi-square statistic and equilibrium verdict.

Related Calculations

Start with the Allele Frequency Calculator to derive p and q from raw counts, or compare against the Heterozygosity Calculator for observed versus expected heterozygosity.