🧬
✓ Editorially reviewed by Derek Giordano, Founder & Editor · BA Business Marketing

Hardy-Weinberg Equilibrium Calculator

Allele frequencies p and q, expected p², 2pq and q², and a chi-square test of equilibrium from genotype counts, checked against OpenStax Biology 2e

Updated October 2026

🧮
700+ calculators, no signup required
Finance · Health · Math · Science · Business
nnng.com
Hardy-Weinberg: p + q = 1 and p² + 2pq + q² = 1, where p and q are the two allele frequencies; p = (2 × AA + Aa) ÷ (2 × individuals). For OpenStax Biology 2e’s 500 pea plants (245 YY, 210 Yy, 45 yy): p = 0.7, q = 0.3; χ² = 0.00, consistent with equilibrium, because the expected 0.49, 0.42 and 0.09 match the observed counts exactly.

How p and q Are Calculated

  1. Count alleles. 500 plants carry 1,000 alleles. Y alleles: 2 × 245 + 210 = 700; y alleles: 2 × 45 + 210 = 300.
  2. Divide: p = 700 ÷ 1,000 = 0.7 and q = 300 ÷ 1,000 = 0.3. They add to 1.
  3. Predict genotypes: p² = 0.49 (YY), 2pq = 0.42 (Yy), q² = 0.09 (yy), which add to 1.
  4. Expected counts: multiply by 500 to get 245, 210 and 45. Here they match the observed counts exactly.

OpenStax’s follow-up question uses p = 0.8 and q = 0.2 in 500 plants: 0.64 × 500 = 320 VV, 0.32 × 500 = 160 Vv and 0.04 × 500 = 20 vv, so 480 violet and 20 white flowers. Choose “dominant allele frequency p” to reproduce it.

Testing for Equilibrium with Chi-Square

Compare observed and expected genotype counts with χ² = Σ (observed − expected)² ÷ expected. There are three genotype classes, minus 1 for the total and minus 1 because p was estimated from the same data, which leaves 1 degree of freedom. The 5% critical value is 3.84.

PopulationpqExpected AA / Aa / aaχ²p-value
OpenStax peas: 245 YY, 210 Yy, 45 yy0.70.3245.0 / 210.0 / 45.00.001.00
Cornell handout: 725 AA, 123 AB, 7 BB0.91990.0801723.5 / 126.0 / 5.50.490.48
Heterozygote shortage (illustrative): 300, 100, 1000.70.3245.0 / 210.0 / 45.0137.191.1e-31
Heterozygote excess (illustrative): 100, 300, 1000.50.5125.0 / 250.0 / 125.020.007.7e-06

The Cornell Statistical Consulting Unit’s handout works the 725 / 123 / 7 example to χ² ≈ 0.49 and says the population is consistent with equilibrium. Its printed p-value, “about 0.104,” does not match: a χ² of 0.49 on 1 degree of freedom has an upper-tail p-value of about 0.48. The conclusion is the same either way. With an expected count near 5 in the rare genotype class, an exact test is the safer choice, as the handout also notes.

From a Recessive Trait to Carrier Frequency

When only the recessive phenotype can be seen, its frequency is q². Take the square root for q, then 2pq gives the share of carriers. These rows are illustrative frequencies, not data for a particular disease:

Recessive phenotypeqpCarriers (2pq)
1 in 1000.10.91 in 6
1 in 1,0000.03160.96841 in 16
1 in 2,5000.020.981 in 26
1 in 10,0000.010.991 in 51
1 in 40,0000.0050.9951 in 101

Carriers far outnumber affected people for rare recessive traits: at 1 in 2,500, about 1 person in 26 carries the allele.

Common Mistakes

What This Calculator Does Not Cover

It handles one gene with two alleles in a diploid population. Multiple alleles, X-linked genes, exact tests for small samples and inbreeding coefficients need other methods.

Frequently Asked Questions

How do you calculate p and q in Hardy-Weinberg?
p = (2 × homozygous dominant + heterozygous) ÷ (2 × total individuals), and q = 1 − p. For 245 YY, 210 Yy and 45 yy, p = 700 ÷ 1,000 = 0.7 and q = 0.3.
What does 2pq represent?
The expected frequency of heterozygotes (carriers) under Hardy-Weinberg equilibrium.
How do you find q from the recessive phenotype?
The recessive phenotype frequency is q², so take its square root. If 9% show the recessive trait, q = 0.3.
How many degrees of freedom does a Hardy-Weinberg chi-square test have?
One, for two alleles: three genotype classes minus one for the total and one for the estimated allele frequency.
What are the Hardy-Weinberg assumptions?
A very large population, random mating, and no mutation, migration or natural selection, per OpenStax Biology 2e.
What does it mean if a population is not in Hardy-Weinberg equilibrium?
Something is changing allele or genotype frequencies, such as selection, non-random mating, migration or genotyping errors.

How to Use This Calculator

  1. Choose what you know — genotype counts, the dominant allele frequency p, or the recessive phenotype frequency q².
  2. Enter the numbers — counts for each genotype, or p or q² as a decimal or 1/N.
  3. Set a population size — for expected counts when starting from a frequency.
  4. Read the results — p, q, p², 2pq, q², expected counts and, from counts, the chi-square test.
📚 Sources & References
  1. [1] OpenStax. Biology 2e, 19.1 Population Evolution (2018; accessed October 2026). openstax.org
  2. [2] Cornell Statistical Consulting Unit. Jing Yang, The Hardy-Weinberg Principle in Population Genetics (2013, updated April 2022). cscu.cornell.edu
✅ Editorial Standards — Every calculator is built from peer-reviewed formulas and official data sources, editorially reviewed for accuracy, and updated regularly. Read our full methodology · About the author