Hardy-Weinberg CalculatorAllele frequencies, genotype frequencies, carrier rates and a chi-square test

Start from whatever your problem gives you: the recessive trait percentage, an allele frequency, a 1-in-N disease rate or raw genotype counts.

p²+2pq+q²= 1
Add DexoCalc as a preferred source on Google

How do you solve a Hardy-Weinberg problem?

Find q first, usually from the recessive phenotype: q² = recessive frequency, so q = √q². Then p = 1 − q, and genotype frequencies are p² (homozygous dominant), 2pq (carriers) and q² (homozygous recessive). Example: if 16% show the recessive trait, q = 0.4, p = 0.6, and 2pq = 0.48, so 48% are carriers.

Share of individuals showing the recessive trait.
Enter as a decimal between 0 and 1.
For an autosomal recessive condition.
Observed numbers of individuals. Runs a chi-square test for equilibrium.
p · dominant allele0.600
q · recessive allele0.400
p²
2pq
q²
AA · p²0.360
Aa · 2pq0.480
aa · q²0.160

De Finetti diagram: every point in the triangle is a possible population. The curve marks Hardy-Weinberg equilibrium; the dot is your population.


   

The two Hardy-Weinberg equations

p + q = 1 describes the two allele frequencies. p² + 2pq + q² = 1 describes the three genotype frequencies after one generation of random mating. Together they let you move from any one known value to all the others.

The five equilibrium conditions

No mutationalleles are not created or changed
Random matingpartners do not choose by genotype
No selectionall genotypes survive and reproduce equally
Large populationno genetic drift by chance
No gene flowno migration in or out

How to use the Hardy-Weinberg calculator

  1. Pick your starting point: recessive phenotype frequency, an allele frequency, a 1-in-N disease incidence, or observed genotype counts.
  2. Enter the value and, optionally, a population size to see expected numbers of people.
  3. Read p, q and the three genotype frequencies, plus carrier frequency as “1 in N”.
  4. With counts, check the chi-square result to see whether the population fits equilibrium.

Worked examples

1. Recessive trait in 16% of a population

q² = 0.16 → q = 0.40 → p = 0.60. Genotypes: AA = 0.36, Aa = 0.48, aa = 0.16. In 1,000 people: 360 AA, 480 carriers, 160 affected.

2. Carrier frequency for cystic fibrosis

With an incidence of about 1 in 2,500 among people of Northern European ancestry: q = √(1/2500) = 0.02, p = 0.98, and 2pq = 0.0392 ≈ 1 in 26 people are carriers, roughly 98 carriers for every affected person.

3. Testing observed counts

A sample has 50 AA, 30 Aa and 20 aa (N = 100). p = (2 × 50 + 30) ÷ 200 = 0.65. Expected: 42.25, 45.5, 12.25. χ² = 11.60 with 1 degree of freedom, p ≈ 0.0007, so the sample is not in equilibrium; heterozygotes are under-represented.

Disease incidence to carrier frequency

Affected (q²)qCarriers (2pq)Carriers per affected
1 in 1000.1001 in 5.618
1 in 1,0000.03161 in 1661
1 in 2,5000.02001 in 2698
1 in 10,0000.01001 in 51198
1 in 100,0000.003161 in 159631

The rarer a recessive condition, the more carriers there are for each affected person. That is why recessive alleles persist in populations even when the condition itself is uncommon.

Hardy-Weinberg FAQs

The Hardy-Weinberg equation is p² + 2pq + q² = 1, where p and q are the frequencies of two alleles (p + q = 1), p² is the frequency of the homozygous dominant genotype, 2pq is heterozygous and q² is homozygous recessive.

The recessive phenotype frequency equals q², so q is its square root. If 16% of a population shows the recessive trait, q = √0.16 = 0.4 and p = 0.6.

Carriers are heterozygotes, so carrier frequency is 2pq. For a recessive condition affecting 1 in 2,500 people, q = 0.02, p = 0.98, and 2pq = 0.0392, or about 1 in 26.

No mutation, random mating, no natural selection, a very large population (no genetic drift) and no gene flow (migration). If all five hold, allele and genotype frequencies stay constant.

Count the observed genotypes, calculate p and q from them, work out expected counts with p², 2pq and q², then run a chi-square test with 1 degree of freedom. A p-value below 0.05 suggests the population departs from equilibrium.

There are three genotype classes, minus one because the counts must sum to the total, minus one more because allele frequency is estimated from the same data, leaving 1 degree of freedom.

Yes, with an adjustment. In males the trait frequency equals q directly, while in females it is q². This calculator handles the standard autosomal case.

It means there are only two alleles for the gene in the population, so their frequencies add up to 100%. If p is 0.7, q must be 0.3.

For rare recessive conditions, 2pq is far larger than q². In the cystic fibrosis example, carriers outnumber affected people about 98 to 1, and carriers usually have no symptoms.

A De Finetti diagram is a triangle where each point represents a population's three genotype frequencies. Populations in Hardy-Weinberg equilibrium fall on a curved line inside the triangle.

The model assumes a very large population. In small populations genetic drift can shift allele frequencies by chance, and the chi-square test becomes unreliable when any expected count is below 5.

It demonstrates the population math only. Real carrier risk depends on ancestry, family history and genetic testing, so use a genetic counselor for personal risk.

Sources

  1. Nature Education Scitable: The Hardy-Weinberg Principle
  2. OpenStax Biology 2e, Section 19.1: Population Evolution
  3. NIH NHGRI: Allele (glossary)
  4. MedlinePlus Genetics: Cystic fibrosis
  5. NIST/SEMATECH e-Handbook: Chi-Square Goodness-of-Fit Test

This Hardy-Weinberg calculator is for education. Disease incidence examples are approximate population figures; personal carrier risk requires genetic testing and counseling.