ThisCalculator

Biology

Hardy-Weinberg Calculations: Formula and Examples

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Hardy-Weinberg Calculations: Formula and Examples

Hardy-Weinberg calculations estimate genotype frequencies from allele frequencies, or infer allele frequencies from genotype data, under a set of population assumptions. Enter the frequency of allele A and the frequency of allele a; the calculator returns the expected frequencies of AA, Aa, and aa, which should add to 1.

Formula

For a gene with two alleles, Hardy-Weinberg equilibrium gives p + q = 1 and p² + 2pq + q² = 1. Here, p is the frequency of allele A and q is the frequency of allele a. The genotype frequencies are AA = p², Aa = 2pq, and aa = q². Frequencies are proportions with no unit; multiply by 100 to express them as percentages.

The calculator takes p as its input and derives q as 1 − p. Its outputs are p², 2p(1 − p), and (1 − p)², respectively. The input must be between 0 and 1 inclusive. The default p = 0.6 therefore means that A makes up 60% of the alleles.

Worked Example

Using the default input, p = 0.6:

  1. Find the other allele frequency: q = 1 − 0.6 = 0.4.
  2. Expected AA frequency: p² = 0.6² = 0.36, or 36%.
  3. Expected heterozygote Aa frequency: 2pq = 2 × 0.6 × 0.4 = 0.48, or 48%.
  4. Expected aa frequency: q² = 0.4² = 0.16, or 16%.

The frequencies sum to 0.36 + 0.48 + 0.16 = 1.00, or 100%. This is a useful arithmetic check: the three expected genotype categories account for the whole population in the model.

What the Hardy-Weinberg Principle Means

The Hardy-Weinberg principle describes a baseline model for how allele and genotype frequencies relate in a population. If a population meets the model’s assumptions, allele frequencies do not change from one generation to the next, and genotype frequencies follow the proportions p², 2pq, and q². It is a mathematical expectation, not a claim that every real population is perfectly static or randomly mating.

The model is commonly introduced for a single gene with two alleles in a diploid population: individuals carry two copies of the gene, one inherited from each parent. The three possible genotypes are AA, Aa, and aa. For a gene with more than two alleles, the general principle still applies, but there are more genotype categories and the two-allele formulas are not sufficient.

How to Calculate from Allele Frequencies

First identify the two allele frequencies. They must be proportions that total 1, so if p = 0.6 then q = 0.4. Then square each allele frequency to obtain the two homozygote frequencies and calculate twice their product for the heterozygote frequency. Convert to percentages only after the calculations, or keep every value as a proportion throughout.

For a population of N individuals, expected genotype counts can be estimated by multiplying each frequency by N. For example, with the default frequencies in a population of 100 individuals, the expected counts are 36 AA, 48 Aa, and 16 aa. These are expected counts; actual observed counts are whole numbers and may differ because of sampling and biological processes.

Calculating Allele Frequencies from Genotype Data

If genotype counts are known, calculate allele frequencies by counting gene copies. With N individuals and counts nAA, nAa, and naa, there are 2N total copies of the gene. The frequency of A is p = (2nAA + nAa) / (2N); the frequency of a is q = (2naa + nAa) / (2N). A homozygote contributes two copies of its allele, while a heterozygote contributes one copy of each.

For example, suppose a sample of 100 individuals contains 36 AA, 48 Aa, and 16 aa. Then p = (2 × 36 + 48) / 200 = 0.6, and q = (2 × 16 + 48) / 200 = 0.4. Substituting these frequencies into the model gives expected counts of 36, 48, and 16. In other datasets, observed and expected counts need not match.

Assumptions, Uses, and Limits

The idealized model assumes a very large population, random mating with respect to the gene, and no effects that change allele frequencies through selection, migration, mutation, or genetic drift. These assumptions are simplifications. A departure between observed genotype counts and Hardy-Weinberg expectations can prompt further investigation, but by itself it does not identify the cause. Sampling variation, population structure, related individuals, or technical errors can also affect results.

Researchers and students use the principle as a reference for understanding inheritance patterns and for comparing observed genotypes with expected proportions. A formal test generally requires observed genotype counts and a statistical method, such as a chi-square test when its conditions are appropriate. The calculator’s expected frequencies alone do not perform that test or establish that a population is in equilibrium.

A common misconception is that equilibrium means allele frequencies are equal. It does not: p can be any value from 0 to 1, with q = 1 − p. Another is that the heterozygote frequency is simply pq; for two alleles in a diploid population it is 2pq, because an A can be inherited from either parent. Keep proportions and percentages distinct, and avoid rounding p or q too early, since rounding can make the final frequencies fail to sum exactly to 1.

Frequently Asked Questions

What is the Hardy-Weinberg equation?
The allele equation is p + q = 1. The genotype equation is p² + 2pq + q² = 1 for a two-allele gene in a diploid population under the model’s assumptions.

How do I find q if I know p?
Use q = 1 − p. For instance, if p is 0.6, q is 0.4. Both values should be proportions and together must equal 1.

How do I calculate heterozygote frequency?
Multiply the two allele frequencies and double the result: 2pq. If p = 0.6 and q = 0.4, the expected heterozygote frequency is 0.48, or 48%.

Can I use Hardy-Weinberg calculations with genotype counts?
Yes. Count two allele copies per individual, then calculate p = (2nAA + nAa)/(2N) and q = (2naa + nAa)/(2N). You can use those allele frequencies to calculate expected genotype frequencies.

Why do observed and expected genotype counts differ?
They can differ because of sampling variation or because one or more model assumptions do not hold. A difference is a signal to examine the data and population context, not proof of a particular cause.

Related

Formula used
in p | Frequency of allele A | - | 0.6 | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.