Proofwell
Menu

Hardy–Weinberg Calculator

Work out allele frequencies (p and q) and expected genotype frequencies (p², 2pq and q²) from genotype counts, the frequency of a recessive trait, or a known allele frequency. With observed counts, you can also test whether a population departs from Hardy–Weinberg equilibrium.

Biology · Population geneticsUpdated Sources cited

What do you know?

Result

✓ No significant deviation from equilibrium

Dominant allele (A)
p = 0.9541
Recessive allele (a)
q = 0.04591
Genotype frequencies and counts
GenotypeExpected frequencyExpected countObserved count
AA (p²)Homozygous dominant0.910391%1467.41469
Aa (2pq)Heterozygous0.08768.76%141.21138
aa (q²)Homozygous recessive0.0021070.211%3.3975
Dominant phenotype (p² + 2pq)
0.9979
Heterozygous carriers
about 1 in 11.4
χ² statistic (1 degree of freedom)
0.8309
p-value
0.362

Warning: At least one expected count is below 5 (smallest: 3.4). The χ² approximation is unreliable for small expected counts; an exact test is more appropriate for this sample.

Assumptions behind this result
  • One gene with two alleles; A is completely dominant over a.
  • Expected frequencies assume random mating, no selection, no mutation, no migration and a very large population.
  • Genotypes are observed directly (for example by genetic testing), so heterozygotes can be told apart from AA individuals.

Step-by-step solution

Every step is computed from your input
  1. Step 1: Find the total number of individuals

    Add the three genotype counts.

    N=1469+138+5=1612N = 1469 + 138 + 5 = 1612
  2. Step 2: Count alleles to find p

    Each individual carries two alleles. AA individuals carry two A alleles and Aa individuals carry one, out of 2N alleles in total. Counting alleles directly does not assume equilibrium.

    p=2(AA)+Aa2N=2×1469+1382×1612=0.954094p = \frac{2(AA) + Aa}{2N} = \frac{2 \times 1469 + 138}{2 \times 1612} = 0.954094
  3. Step 3: Find q

    The two allele frequencies add up to 1.

    q=1−p=1−0.954094=0.0459057q = 1 - p = 1 - 0.954094 = 0.0459057
  4. Step 4: Calculate the expected genotype frequencies

    Under Hardy–Weinberg equilibrium, genotype frequencies follow p² + 2pq + q² = 1. The three values must add up to 1.

    AA=p2=0.9540942=0.910296Aa=2pq=2×0.954094×0.0459057=0.0875967aa=q2=0.04590572=0.00210733\begin{aligned} AA &= p^2 = 0.954094^2 = 0.910296 \\ Aa &= 2pq = 2 \times 0.954094 \times 0.0459057 = 0.0875967 \\ aa &= q^2 = 0.0459057^2 = 0.00210733 \end{aligned}
  5. Step 5: Convert frequencies to expected numbers of individuals

    Multiply each frequency by the population size, N = 1612. Expected numbers can be fractional; they are averages, not head counts.

    AA=0.910296×1612=1467.4Aa=0.0875967×1612=141.206aa=0.00210733×1612=3.39702\begin{aligned} AA &= 0.910296 \times 1612 = 1467.4 \\ Aa &= 0.0875967 \times 1612 = 141.206 \\ aa &= 0.00210733 \times 1612 = 3.39702 \end{aligned}
  6. Step 6: Compare observed and expected counts with a χ² test

    For each genotype, square the difference between the observed (O) and expected (E) counts and divide by E. Then add the three terms.

    χ2=∑(O−E)2E=(1469−1467.4)21467.4+(138−141.206)2141.206+(5−3.39702)23.39702=0.8309\chi^2 = \sum \frac{(O-E)^2}{E} = \frac{(1469 - 1467.4)^2}{1467.4} + \frac{(138 - 141.206)^2}{141.206} + \frac{(5 - 3.39702)^2}{3.39702} = 0.8309
  7. Step 7: Find the p-value with 1 degree of freedom

    There are 3 genotype classes. Subtract 1 because the counts must add up to N, and 1 more because p was estimated from the same data. That leaves 1 degree of freedom.

    P(χ12≥0.8309)=0.362P(\chi^2_1 \ge 0.8309) = 0.362
  8. Step 8: Interpret the result at the 5% significance level

    Because p = 0.362 is at least 0.05, the observed genotype counts are not significantly different from Hardy–Weinberg expectations. This does not prove the population is in equilibrium; it means this sample gives no significant evidence against it.

What the calculator does

The Hardy–Weinberg principle describes how allele and genotype frequencies relate to each other in a population that is not evolving. For one gene with two alleles, a dominant allele A and a recessive allele a, this calculator gives you:

  • the allele frequencies p (for A) and q (for a);
  • the expected genotype frequencies p² (AA), 2pq (Aa) and q² (aa);
  • expected numbers of individuals, if you give a population size;
  • a χ² goodness-of-fit test, if you enter observed genotype counts.

How to use it

Choose the option that matches the information you have.

  • Genotype counts. Use this when you know how many individuals have each genotype, for example from genetic testing. The calculator counts alleles directly and then tests whether the counts fit Hardy–Weinberg proportions.
  • Recessive phenotype. Use this when you know how common a recessive trait is, such as 1 in 2,500. Enter it as a decimal, a fraction (1/2500) or a percentage (0.04%).
  • Allele frequency. Use this when you already know p or q.

Then press Calculate. Results appear alongside the form, with the full working below.

The formulas

The two allele frequencies account for every allele in the population, so they add up to 1:

p+q=1p + q = 1

When mating is random, the two alleles an individual inherits are like two independent draws from the population’s allele pool. That gives the genotype frequencies:

p2+2pq+q2=1p^2 + 2pq + q^2 = 1

The heterozygote term is 2pq rather than pq because an Aa individual can inherit A from either parent: A from the mother and a from the father, or the other way round.

Variables

Symbol Meaning
p Frequency of the dominant allele, A
q Frequency of the recessive allele, a
p² Expected frequency of homozygous dominant individuals (AA)
2pq Expected frequency of heterozygous individuals (Aa), the carriers of a recessive trait
q² Expected frequency of homozygous recessive individuals (aa)
N Number of individuals in the sample or population

Allele frequencies from genotype counts

When genotypes can be counted, p comes from counting alleles. Each AA individual carries two A alleles, each Aa individual carries one, and there are 2N alleles in total:

p=2(AA)+Aa2Np = \frac{2(AA) + Aa}{2N}

This does not assume equilibrium, which is what makes it possible to test for equilibrium afterwards.

Worked example

In a classic study, E. B. Ford recorded genotypes in a colony of scarlet tiger moths (Callimorpha dominula). The colour pattern gene has three distinguishable genotypes. The sample contained 1,469 AA, 138 Aa and 5 aa moths, a total of N = 1,612.

  1. Count the alleles. p = (2 × 1469 + 138) / (2 × 1612) = 3076 / 3224 = 0.9541.
  2. Find q. q = 1 − p = 0.04591.
  3. Expected genotype frequencies. p² = 0.9103, 2pq = 0.0876 and q² = 0.002107.
  4. Expected counts. Multiplying by 1,612 gives 1467 AA, 141.2 Aa and 3.397 aa.
  5. χ² test. Comparing these with the observed 1,469, 138 and 5 gives χ² = 0.8309 with 1 degree of freedom, p-value = 0.362.

The p-value is well above 0.05, so the observed genotypes are consistent with Hardy–Weinberg proportions. The expected aa count of 3.397 is below 5, so the calculator also warns that the χ² approximation is unreliable here. An exact test would be the more rigorous choice.

Testing a population for equilibrium

With observed genotype counts, the calculator compares each observed count (O) with its expected count (E):

χ2=∑(O−E)2E\chi^2 = \sum \frac{(O - E)^2}{E}

The statistic is compared with a χ² distribution with 1 degree of freedom. A p-value below 0.05 means the genotype counts differ more than chance alone would usually produce. A p-value of 0.05 or above means there is no significant evidence of a departure. It does not prove the population is in equilibrium.

When any expected count is below 5, the χ² approximation becomes unreliable, and the calculator tells you so. Exact tests, as described by Wigginton and colleagues (2005), are preferred for small samples or rare alleles.

Common mistakes

  • Taking p as the square root of the dominant phenotype frequency. The dominant phenotype includes both AA and Aa individuals, so its frequency is p² + 2pq, not p². Always start from the recessive phenotype, q².
  • Confusing p with p². p is an allele frequency; p² is a genotype frequency. If p = 0.6, the frequency of AA individuals is 0.36, not 0.6.
  • Forgetting the 2 in 2pq. Heterozygotes can arise in two ways, so their frequency is twice pq.
  • Treating “not significant” as proof. A non-significant χ² result only means no departure was detected.
  • Using phenotype data to test for equilibrium. If you calculated q from the recessive phenotype, you already assumed equilibrium. You cannot then use the same data to test it.

Practical applications

  • Genetic counselling and public health. Estimating carrier frequencies for recessive conditions from how often the condition occurs.
  • Quality control in genetic studies. Genome-wide association studies routinely test each genetic marker for Hardy–Weinberg equilibrium. Strong departures can reveal genotyping errors.
  • Evolutionary biology. Departures from expected proportions can point to selection, inbreeding, population structure or migration.
  • Conservation genetics. Monitoring genetic diversity and inbreeding in small or isolated populations.

Assumptions and limitations

Hardy–Weinberg expectations hold only in an idealised population: mating is random, there is no selection, mutation or migration, and the population is large enough for chance changes in allele frequency (genetic drift) to be negligible. Real populations never meet all of these exactly, which is why the principle is useful as a baseline to measure against.

This calculator handles one gene with two alleles, with A completely dominant over a. It does not cover genes with three or more alleles, such as the ABO blood group, or sex-linked genes, which have different expected frequencies in males and females.

Frequently asked questions

What is the difference between p and p²?

p is the frequency of the A allele among all the alleles in the population. p² is the frequency of AA individuals, the chance that both alleles an individual inherits are A. If p = 0.7, then 70% of alleles are A but only 49% of individuals are AA.

Can I use the Hardy–Weinberg equation if I only know how common a recessive trait is?

Yes, but only by assuming the population is already in equilibrium. The recessive trait frequency gives q², so q is its square root. Because AA and Aa individuals look the same, phenotype data alone cannot test that assumption.

Does a non-significant χ² result prove the population is in equilibrium?

No. It means the sample gives no significant evidence against equilibrium. Small samples have little power to detect real departures, so a non-significant result is weaker evidence than it may appear.

Why does the χ² test have only 1 degree of freedom when there are 3 genotypes?

There are three genotype classes. One degree of freedom is lost because the counts must add up to the sample size, and another because the allele frequency p is estimated from the same data. That leaves 3 − 1 − 1 = 1.

What does 2pq tell me?

2pq is the expected frequency of heterozygotes. For a recessive genetic condition, these are the carriers, who have one copy of the allele but do not show the trait. Carriers are usually far more common than affected individuals.

References

  1. Hardy, G. H. (1908). Mendelian proportions in a mixed population. Science, 28(706), 49–50.
  2. Weinberg, W. (1908). Über den Nachweis der Vererbung beim Menschen. Jahreshefte des Vereins für vaterländische Naturkunde in Württemberg, 64, 368–382.
  3. Ford, E. B. (1971). Ecological Genetics (3rd ed.). Chapman and Hall. Source of the scarlet tiger moth data.
  4. Wigginton, J. E., Cutler, D. J. & Abecasis, G. R. (2005). A note on exact tests of Hardy–Weinberg equilibrium. American Journal of Human Genetics, 76(5), 887–893.
  5. NIST/SEMATECH e-Handbook of Statistical Methods. Critical values of the chi-square distribution.