ThisCalculator

Biology

Hardy-Weinberg Equation: 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 Equation: Calculate Allele Frequencies

The Hardy-Weinberg calculator estimates allele and genotype frequencies for a two-allele population under the Hardy-Weinberg model. Enter the frequency of one allele, p, or the observed frequency of a homozygous recessive genotype, q²; the calculator returns p, q, and the expected genotype frequencies. Use it as a model-based estimate, not proof that a population is evolving or not evolving.

Formula

For a gene with two alleles, A and a, the allele frequencies are p + q = 1. Under Hardy-Weinberg equilibrium, expected genotype frequencies are p² + 2pq + q² = 1.

  • p is the frequency of allele A, from 0 to 1; it has no unit.
  • q is the frequency of allele a, from 0 to 1; it has no unit.
  • p² is the expected frequency of genotype AA.
  • 2pq is the expected frequency of genotype Aa.
  • q² is the expected frequency of genotype aa.

Frequencies can be written as decimals, fractions, or percentages, but enter decimals in this calculator: for example, 60% is 0.60. The calculation assumes exactly two alleles at the gene being considered. If you know q² rather than p, first find q = √q² and then p = 1 − q. This calculator takes p as its input, so convert a known q² to p before entering it.

Worked Example

Using the default input, p = 0.6:

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

The calculator displays q = 0.400, AA = 0.360, Aa = 0.480, and aa = 0.160. These correspond to 40%, 36%, 48%, and 16% of the population, respectively.

What You’ll Need

  • A frequency for one allele, entered as a decimal between 0 and 1. You may instead have genotype counts or a recessive-phenotype frequency and convert those into the required input.
  • If starting with counts, a sample of individuals scored for the same gene and the number of copies of each allele. In diploid organisms, each individual usually contributes two copies of the gene.
  • A clear definition of the population and gene you are analyzing. The model is most useful when the sample represents a single, appropriately defined population.

Step-by-Step

  1. Choose the gene and population. Identify the specific locus and the group of individuals you want to describe. Do not combine distinct populations without considering that their allele frequencies may differ.
  2. Get an allele frequency. If you already know p, enter it directly as a decimal. If you have genotype counts for AA, Aa, and aa, let the total number of individuals be N. Count two A copies for each AA individual and one A copy for each Aa individual: p = (2 × AA + Aa) / (2N). Likewise, q = (2 × aa + Aa) / (2N).
  3. Check the input. Confirm that p is at least 0 and no greater than 1. If you calculated q instead, convert using p = 1 − q. If the only known value is the recessive genotype frequency q², take its square root to get q, then calculate p = 1 − q.
  4. Enter p in the calculator. Use a decimal such as 0.6, not 60. The calculator treats p as the frequency of allele A and calculates q as the remaining allele frequency.
  5. Read the expected genotype frequencies. The outputs give the model’s expected proportions for AA, Aa, and aa. Multiply each proportion by the population size N to estimate the corresponding number of individuals. Because individuals are whole numbers, these estimates may need rounding, so the rounded counts might not sum exactly to N.
  6. Check the frequency totals. Verify p + q = 1 and p² + 2pq + q² = 1, allowing for small differences caused by rounding. If either sum is substantially different from 1, check the input and arithmetic.
  7. Compare with observations if appropriate. The calculator predicts frequencies under the model. To assess whether observed genotype counts fit those expectations, compare observed counts with expected counts using a suitable statistical test; the calculator does not perform that test.

Common Mistakes

  • Entering a percentage as a whole number. Enter 0.25 for 25%, not 25. Values outside 0–1 are not valid allele frequencies.
  • Confusing q with q². q is an allele frequency; q² is the expected frequency of homozygous recessive individuals. If a recessive phenotype frequency is 0.09 under the model, q is √0.09 = 0.3, not 0.09.
  • Using genotype proportions as allele frequencies. An observed heterozygote frequency is not the same as p or q. Calculate allele frequencies from allele-copy counts, or use a justified recessive-frequency method.
  • Mixing counts and proportions. Add counts to find N, and divide by N when finding genotype proportions. For allele frequencies in diploid individuals, the denominator is 2N allele copies.
  • Treating expected values as observed facts. Hardy-Weinberg frequencies are predictions under assumptions. They do not show that the real population has those exact proportions.

Tips

  • Keep full precision while calculating, then round the final results. The displayed three decimal places are for readability; rounding intermediate values can make the totals drift.
  • Label alleles and genotypes consistently. If your study calls the recessive allele A instead of a, the symbols can be swapped, but the frequency and genotype labels must follow that choice.
  • When turning frequencies into expected counts, use the same population size and sampling unit as the observed data.
  • Check whether the gene is autosomal and the organisms are diploid before using the usual two-copy formulas. Sex-linked genes and organisms with different ploidy need a model appropriate to their inheritance.

Troubleshooting

  • The calculator rejects the value: enter p as a decimal from 0 to 1. Remove a percent sign and convert percentages by dividing by 100.
  • The outputs do not add to 1: use p + q = 1 and check that the three genotype frequencies are p², 2pq, and q². A tiny discrepancy can come from displayed rounding; a larger one usually signals a calculation or transcription error.
  • Your observed genotype proportions differ from the predictions: first verify genotype identification, sample size, and allele-frequency calculations. Differences can also arise from sampling variation or departures from model assumptions, such as non-random mating, migration, mutation, selection, or a small population. A difference alone does not identify its cause.
  • You have more than two alleles: the simple p and q version is insufficient. For multiple alleles, use the appropriate multi-allele Hardy-Weinberg model and account for every allele frequency.

Frequently Asked Questions

What does the Hardy-Weinberg equation calculate?
It gives expected allele and genotype frequencies for a population under specified assumptions. For two alleles, p + q = 1 and p² + 2pq + q² = 1.

How do I find p and q from genotype counts?
For N diploid individuals, p = (2AA + Aa)/(2N) and q = (2aa + Aa)/(2N), where AA, Aa, and aa stand for the observed counts. The two allele frequencies should add to 1.

How do I calculate a recessive allele frequency from a recessive phenotype?
If the phenotype corresponds only to aa and the population fits the model, its frequency is q². Take the square root to find q, then calculate p = 1 − q. The assumptions matter; the phenotype frequency alone does not prove equilibrium.

Do genotype frequencies have units?
No. They are proportions between 0 and 1, or percentages when multiplied by 100. Multiply a genotype frequency by the number of individuals to get an expected count.

Does a Hardy-Weinberg result prove a population is not evolving?
No. It is a model prediction and a useful comparison. A match does not prove every assumption holds, and a mismatch does not identify which evolutionary or sampling factor caused it.

Can I use the equation for a sex-linked gene?
Not automatically. Allele-copy numbers and genotype frequencies can differ between sexes for sex-linked genes, so use a model that reflects the gene’s inheritance and the population being studied.

Related

Formula used
in p | Frequency of allele A (p) | - | 0.6 | 0
out q | Frequency of allele a (q) | - | 1 - p | 3
out AA | Expected frequency of AA (p²) | - | p ^ 2 | 3
out Aa | Expected frequency of Aa (2pq) | - | 2 * p * q | 3
out aa | Expected frequency of aa (q²) | - | q ^ 2 | 3

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.