Skip to content

Hardy–Weinberg Calculator

Enter one known value — q², q, p, p² or the heterozygote frequency — and get every allele and genotype frequency, the carrier rate and, if you give a population size, the expected head counts. Or enter observed AA, Aa and aa counts and test whether the population is in Hardy–Weinberg equilibrium, with χ², an exact p-value and the inbreeding coefficient. Free, no sign-up.

What do you want to do?

A decimal (0.0004), a percentage (0.04%), or a fraction (1/2500). Between 0 and 1.

Add a size to turn each frequency into an expected head count.

Results

0.98

p — allele A

0.02

q — allele a

0.0392

2pq — genotype Aa

QuantityFrequencyPercent
p — allele A0.9898%
q — allele a0.022%
p² — genotype AA0.960496.04%
2pq — genotype Aa0.03923.92%
q² — genotype aa0.00040.04%
  • Dominant phenotype (AA + Aa): 0.9996
  • Heterozygotes: 1 in 25.5
  • Recessive homozygotes: 1 in 2,500
  • p + q = 1, and p² + 2pq + q² = 1

How to Use the Hardy–Weinberg Calculator

  1. 1. Choose the job. Find frequencies works from one known number; Test genotype counts checks real data against the expected proportions.
  2. 2. Enter what you know. For the first job, pick the quantity (most often q², the frequency of the recessive phenotype) and type it as a decimal, a percentage or a fraction such as 1/2500. Add a population size to get head counts. For the test, type the observed AA, Aa and aa counts.
  3. 3. Read the table. You get p and q, the three genotype frequencies, the carrier rate as 1 in N, and a check that p + q = 1.
  4. 4. Interpret the test. A small p-value means the genotype counts differ from Hardy–Weinberg proportions; the heterozygosity line and F say in which direction.

The Hardy–Weinberg Equations

For one locus with two alleles, A at frequency p and a at frequency q, the allele frequencies sum to one: p + q = 1. After one generation of random mating the genotypes appear in the proportions p² (AA), 2pq (Aa) and q² (aa), which also sum to one: p² + 2pq + q² = 1. G. H. Hardy and Wilhelm Weinberg published this independently in 1908 (Hardy in Science, Weinberg in a German journal). It is the null model of population genetics: if nothing changes allele frequencies, they stay put, and genotype frequencies settle into these proportions after a single generation.

Assumptions Behind the Model

  • Random mating — individuals pair without regard to genotype at this locus.
  • No selection — all genotypes survive and reproduce equally.
  • No mutation and no migration — no new alleles arrive and none are lost to gene flow.
  • A large population — random drift is negligible; in small populations frequencies wander by chance.
  • A diploid, sexually reproducing species with equal allele frequencies in males and females and non-overlapping generations.

Real populations never meet every condition exactly. The model is useful because the departures are informative: a heterozygote deficit suggests inbreeding, population structure or a genotyping fault, and a surplus suggests selection favouring heterozygotes.

Worked Example: Carrier Frequency

Suppose an autosomal recessive condition affects 1 person in 2,500. Only aa people are affected, so q² = 1/2500 = 0.0004. Choose q² and type 1/2500.

From q² to the carrier rate

q = √0.0004 = 0.02, so p = 1 − 0.02 = 0.98

p² = 0.9604 (AA), 2pq = 2 × 0.98 × 0.02 = 0.0392 (Aa), q² = 0.0004 (aa)

Carriers: 1 in 25.5 — about 392 in a population of 10,000

The surprise is how common carriers are: 4% of the population carries the allele although only 0.04% is affected. Because most copies of a rare recessive allele sit in heterozygotes, where selection cannot see them, such alleles persist. The calculation assumes the population is in equilibrium and that the affected are all aa — for a condition with incomplete penetrance it understates q. Enter a heterozygote frequency instead and the tool shows both solutions: 2pq = 0.32 fits p = 0.8 with q = 0.2, or the reverse.

Testing Genotype Counts

The test estimates p from your sample, p = (2·AA + Aa) / 2N, computes the expected counts N·p², 2N·pq and N·q², and sums (O − E)² / E over the three genotypes. It has one degree of freedom: three classes, minus one because the counts must total N, minus one because p was estimated from the same data.

Counts (AA / Aa / aa)Expectedχ²p-valueReading
55 / 40 / 556.25 / 37.5 / 6.250.44.505Consistent with equilibrium; F = −0.07
90 / 60 / 5072 / 96 / 3228.13< .001Heterozygote deficit; F = 0.375
8 / 3 / 17.52 / 3.96 / 0.520.70.402 (exact .404)Expected count below 5: trust the exact test

The chi-square p-value is an approximation that fails when expected counts are small, and Wigginton, Cutler and Abecasis (2005, American Journal of Human Genetics) showed it can also misbehave in large samples when the minor allele is rare. The calculator therefore also reports the exact test they described, which sums the probabilities of every heterozygote count, given the allele counts, that is no more likely than the one you observed. When any expected count is below 5 the verdict uses the exact p-value. The fixation-style index F = (Hₑ − Hₒ) / Hₑ is positive for a shortage of heterozygotes and negative for an excess. Compare a chi-square result by hand with the chi-square calculator.

Frequently Asked Questions

What are the assumptions of Hardy–Weinberg equilibrium?
Random mating, no natural selection at the locus, no mutation, no migration, and a population large enough that genetic drift is negligible. The model also assumes a diploid, sexually reproducing species with non-overlapping generations and the same allele frequencies in both sexes. Violating any one of them can push genotype frequencies away from p², 2pq and q².
How do you find the carrier frequency from disease incidence?
Take the incidence of the recessive condition as q², take its square root to get q, and subtract from 1 to get p. The carrier frequency is 2pq. For an incidence of 1 in 10,000, q = 0.01, p = 0.99 and 2pq = 0.0198, roughly 1 carrier in 50.
Why does the Hardy–Weinberg chi-square test have one degree of freedom?
There are three genotype classes, which would give 2 degrees of freedom, but p is estimated from the same data, which uses one more. The test therefore has 3 − 1 − 1 = 1 degree of freedom. Using 2 is a common mistake and makes p-values too large.
What should I do when expected counts are small?
Use the exact test. The chi-square approximation is unreliable when any expected count is below about 5, which is common for rare alleles. The exact p-value is computed from the full distribution of heterozygote counts, so it stays valid at any sample size.
What does it mean if my population is not in Hardy–Weinberg equilibrium?
At least one assumption fails, or the data are flawed. A deficit of heterozygotes points to inbreeding, a mixture of subpopulations (the Wahlund effect) or genotyping errors such as missed heterozygous calls; an excess of heterozygotes can indicate selection favouring them. A significant result tells you something is off, not what.
Does this calculator handle X-linked traits or three alleles?
No. It covers one autosomal locus with two alleles. For an X-linked recessive trait the frequency of affected males equals q, and affected females occur at q², so you can enter the male frequency as q. Systems with three or more alleles, such as ABO blood groups, extend the same idea to (p + q + r)² and need a different calculation.

Related Tools

More in Science & Lab Calculators

See all Science & Lab Calculators