ThisCalculator

Biology

Hardy-Weinberg Formula: Calculate Allele Frequencies

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 Formula: Calculate Allele Frequencies

The Hardy-Weinberg formulas calculate expected allele and genotype frequencies in a population from the frequencies of two alleles. Enter the frequency of allele A to get the expected frequencies of AA, Aa, and aa; the calculator also shows the frequency of allele a.

Formula

For a gene with two alleles, A and a, the Hardy-Weinberg equations are p + q = 1 and p² + 2pq + q² = 1. Here, p is the frequency of allele A, q is the frequency of allele a, and both are dimensionless proportions from 0 to 1. The genotype frequencies are p² for AA, 2pq for Aa, and q² for aa. The calculator takes p as its input and finds q and all three expected genotype frequencies. Multiply a frequency by 100 to express it as a percentage.

Worked Example

Using the default input, p = 0.6:

  1. Find the other allele frequency: q = 1 − p = 1 − 0.6 = 0.4.
  2. Find the expected AA frequency: p² = 0.6² = 0.36.
  3. Find the expected Aa frequency: 2pq = 2 × 0.6 × 0.4 = 0.48.
  4. Find the expected aa frequency: q² = 0.4² = 0.16.

The results are q = 0.40, AA = 0.36, Aa = 0.48, and aa = 0.16. The genotype frequencies sum to 0.36 + 0.48 + 0.16 = 1.00, as they should.

What the Hardy-Weinberg Principle Means

The Hardy-Weinberg principle is a model describing how allele and genotype frequencies relate in an idealized population. If its assumptions hold, allele frequencies remain constant from one generation to the next, and genotype frequencies are given by p², 2pq, and q². The equations are named after mathematician G. H. Hardy and physician Wilhelm Weinberg, who independently described the result in 1908.

It is a useful baseline, not a claim that real populations never change. Biologists compare observed genotype frequencies with Hardy-Weinberg expectations to investigate possible evolutionary forces, population structure, or data problems. A difference from expectation is a clue to examine, not by itself proof of a particular cause.

How to Use the Equations

Allele frequency counts copies of alleles, while genotype frequency counts individuals with particular allele combinations. For a diploid population, each individual has two copies of the gene in question. If genotype counts are available, calculate allele frequencies by counting allele copies:

  • p = (2 × number of AA individuals + number of Aa individuals) ÷ (2 × total individuals)
  • q = (2 × number of aa individuals + number of Aa individuals) ÷ (2 × total individuals)

For example, heterozygotes contribute one A and one a copy. Once p and q are known, use the Hardy-Weinberg equations to calculate expected proportions. To estimate expected counts, multiply each expected genotype frequency by the total number of individuals. Counts may not be whole numbers before rounding, because they are statistical expectations.

The calculator uses p as the input, so its answer assumes the population has two alleles at this gene and that p is a valid frequency between zero and one. If you start with q instead, swap the allele labels: p = 1 − q. A frequency of 0.6 means 60%, not 0.6%.

Assumptions and Limits

The basic model assumes a very large population with random mating and no significant mutation, migration, natural selection, or genetic drift affecting the gene. In practice, these conditions are approximations. Small populations can change in allele frequency by chance; migration can introduce alleles; selection can change reproductive success; and nonrandom mating can alter genotype frequencies.

The simple equations also apply to a single gene with two alleles in a diploid population. Genes with more than two alleles require a generalized form: each allele frequency is squared for its homozygote genotype, and each pair of distinct alleles contributes twice the product of their frequencies. Sex-linked genes and organisms with different inheritance patterns can require a different calculation.

Rounding p and q too early can make the genotype frequencies fail to sum exactly to 1. Keep full precision during the calculation, then round the displayed results. If observed data are being compared with expected values, sample size and an appropriate statistical test matter; a small difference can arise from sampling variation alone.

Interpreting a Hardy-Weinberg Comparison

Suppose observed genotypes are counted in a sample. First estimate p and q from those allele counts, then calculate the expected genotype counts under the model. Compare observed and expected counts using a suitable method, such as a chi-square test when its conditions are met. The exact method depends on sample size, study design, and whether allele frequencies were estimated from the same data.

A mismatch can have several explanations: nonrandom mating, population subdivision, selection, migration, mutation, chance, or errors in sampling or genotype measurement. These possibilities can produce similar patterns, so researchers consider the biological context and study methods rather than treating the equation as a diagnosis.

Frequently Asked Questions

What is the Hardy-Weinberg formula?
The allele equation is p + q = 1. The genotype equation is p² + 2pq + q² = 1, giving expected frequencies for two homozygotes and the heterozygote.

How do I calculate q if I know p?
Use q = 1 − p. For example, if p is 0.6, q is 0.4.

Why is the heterozygote frequency 2pq?
An A allele from one parent and an a allele from the other can occur in two orders: A then a, or a then A. Their combined probability is pq + qp = 2pq.

Can I find allele frequency from a recessive phenotype?
Only under additional assumptions. If a phenotype is caused by a fully recessive genotype aa, and the population is in Hardy-Weinberg equilibrium, its frequency is q², so q is the square root of that frequency. The assumptions and phenotype-to-genotype relationship must be justified.

Does a deviation from Hardy-Weinberg equilibrium prove evolution?
No. It indicates that observed genotype frequencies differ from the model expectation, but sampling error, population structure, nonrandom mating, selection, or technical issues may be responsible. More evidence is needed to identify a cause.

Related

Formula used
in p | Frequency of allele A | proportion | 0.6 | 0
out q | Frequency of allele a | proportion | 1 - p | 2
out AA | Expected frequency of genotype AA | proportion | p ^ 2 | 2
out Aa | Expected frequency of genotype Aa | proportion | 2 * p * q | 2
out aa | Expected frequency of genotype aa | proportion | q ^ 2 | 2

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.