Illustration of a herd of cattle in black, red and roan coat colors standing in a pasture

Free tool · Calculators

Hardy-Weinberg equilibrium calculator

The Hardy-Weinberg equilibrium equation is p² + 2pq + q² = 1, where p and q are the frequencies of two alleles (p + q = 1) and p², 2pq and q² are the expected genotype frequencies. To test a population, count genotypes, work out p and q, compare observed with expected counts using a chi-square test with 1 degree of freedom (LibreTexts). The calculator below does every step.

On this page

At a glance

What is the Hardy-Weinberg equation?
p² + 2pq + q² = 1 for genotype frequencies, with p + q = 1 for the two allele frequencies. Read more about what is the hardy-weinberg equation
What are p and q?
The frequencies of the two alleles. p = (2 × AA + Aa) ÷ (2 × total), which is the AA frequency plus half the Aa frequency (LibreTexts). Read more about what are p and q
How do you test for Hardy-Weinberg equilibrium?
Compare observed and expected genotype counts with a chi-square test. With three genotypes and one estimated allele frequency there is 1 degree of freedom (LibreTexts). Read more about how do you test for hardy-weinberg equilibrium
What are the Hardy-Weinberg assumptions?
Diploid, sexual reproduction, non-overlapping generations, random mating, a large population, equal allele frequencies in both sexes, and no migration, mutation or selection (Bosco et al. 2012). Read more about what are the hardy-weinberg assumptions
Can the chi-square test mislead?
Yes. It relies on asymptotic results and can wrongly reject or accept equilibrium when samples are small or some genotypes are rare (Lauretto et al. 2009). Read more about can the chi-square test mislead

Hardy-Weinberg calculator

Enter the number of individuals of each genotype for one gene with two alleles.

This calculator needs JavaScript. If it remains unavailable, use the written explanation and reference figures on this page.

The equations

  • Allele frequencies: p + q = 1
  • Genotype frequencies: p² (AA) + 2pq (Aa) + q² (aa) = 1

How to do Hardy-Weinberg problems

  1. Count individuals: AA, Aa and aa.
  2. p = (2 × AA + Aa) ÷ (2 × total); q = 1 − p.
  3. Expected counts: p² × total, 2pq × total, q² × total.
  4. Chi-square = Σ (observed − expected)² ÷ expected, with 1 degree of freedom.

Worked example from LibreTexts: 200 AA, 400 Aa and 400 aa give p = 0.400 and q = 0.600, expected counts of 160, 480 and 360, and a chi-square of 27.77 (27.78 without rounding each term), so the population is not in equilibrium. These are the calculator's default numbers.

Assumptions and limits

The principle assumes diploid, sexually reproducing organisms with non-overlapping generations, random mating, a large population, equal allele frequencies in males and females, and no migration, mutation or selection (Bosco et al. 2012). The chi-square test relies on asymptotic results and can falsely reject or accept equilibrium when samples are small or some genotypes are rare (Lauretto et al. 2009). For very small counts, ask a statistician about an exact test.

In livestock breeding, genotype frequencies like these feed into genomic studies such as our genome-wide association study of beef heifers.

Frequently asked questions

Is Hardy-Weinberg equilibrium possible in nature?

Its seven conditions are idealized (Bosco et al. 2012), so real populations only approximate it. That is why it is used as a null model: you test whether observed genotypes fit the expected proportions (LibreTexts).

What does a significant chi-square mean?

That the genotype counts differ from Hardy-Weinberg expectations more than chance alone would explain at your chosen level. It tells you something departs from the assumptions (for example, non-random mating, selection or genotyping error), not which one.

Why is there only 1 degree of freedom?

Three genotype classes, minus 1 for the total, minus 1 for the allele frequency estimated from the same data: 3 − (1 + 1) = 1 (LibreTexts).

Sources

  1. Biology LibreTexts. Is a population in Hardy-Weinberg equilibrium? (Modern Genetics, 11.2). Allele frequencies, expected counts, chi-square example, degrees of freedom
  2. Bosco F, Castro D, Briones MRS. Neutral and stable equilibria of genetic systems and the Hardy–Weinberg principle. Front Genet 2012;3:276. The seven conditions of the principle
  3. Lauretto MS, Nakano F, Faria SR Jr, Pereira CAB, Stern JM. A straightforward multiallelic significance test for the Hardy-Weinberg equilibrium law. Genet Mol Biol 2009;32(3):619–625. Chi-square limits with small samples or rare genotypes

This page is general education, not a diagnosis or prescription. Always confirm doses and treatment with your veterinarian.

All free tools

Research · Livestock projects · Talks

Contact

Email works best if you would like to reach Dr. Muhammad Anas. Give me a few days to reply, sometimes longer if I'm travelling.