ThisCalculator

Biology

Hardy-Weinberg Equilibrium Calculator

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 Equilibrium Calculator

This Hardy-Weinberg equilibrium calculator determines allele and genotype frequencies for a population under the assumptions of the Hardy-Weinberg principle. You enter the number of individuals of each genotype (or the observed allele frequency), and the calculator returns the allele frequencies (p and q), expected genotype frequencies, and whether the population is in equilibrium. The results help you quickly check if a population is evolving at a specific gene locus.

Formula

The Hardy-Weinberg equation describes the relationship between allele frequencies and genotype frequencies in a population that is not evolving. For a gene with two alleles, A and a, let p be the frequency of allele A and q be the frequency of allele a. Since these are the only two alleles, p + q = 1. The expected genotype frequencies are given by:

(p + q)² = p² + 2pq + q² = 1

  • p² = frequency of AA genotype
  • 2pq = frequency of Aa genotype
  • q² = frequency of aa genotype

To calculate p and q from genotype counts (AA, Aa, aa), use the allele-counting method:

p = (2 × count(AA) + count(Aa)) / (2 × total individuals)

q = (2 × count(aa) + count(Aa)) / (2 × total individuals)

Equivalently, p = (count(AA) + 0.5 × count(Aa)) / total, and q = (count(aa) + 0.5 × count(Aa)) / total.

Worked Example

Using the default values from the calculator: 40 AA, 40 Aa, and 20 aa individuals (total = 100).

  1. Calculate allele frequencies:
    p = (40 + 0.5 × 40) / 100 = (40 + 20) / 100 = 0.60
    q = (20 + 0.5 × 40) / 100 = (20 + 20) / 100 = 0.40
  2. Check p + q = 0.60 + 0.40 = 1.0 ✓
  3. Calculate expected genotype frequencies:
    p² = 0.60² = 0.36 (AA)
    2pq = 2 × 0.60 × 0.40 = 0.48 (Aa)
    q² = 0.40² = 0.16 (aa)
  4. Convert to expected counts (multiply by total, 100):
    AA: 36, Aa: 48, aa: 16

The calculator shows p = 0.600, q = 0.400, and the expected genotype frequencies as 0.360, 0.480, and 0.160. The observed genotype frequencies are 0.40, 0.40, and 0.20, which differ from expected, suggesting the population may not be in Hardy-Weinberg equilibrium for this gene.

When to Use the Hardy-Weinberg Equation

The Hardy-Weinberg principle serves as a null model in population genetics. Use it when:

  • You have genotype counts from a sample and want to estimate allele frequencies.
  • You want to test whether a population is experiencing evolution at a specific locus (by comparing observed and expected genotype frequencies).
  • You need to estimate the frequency of carriers of a recessive allele, for example in genetic counseling (if the disorder is in equilibrium).
  • You are studying a single gene with two alleles and a clear dominance relationship.

The equation is most useful in educational settings, basic research, and as a starting point for more complex models. It is not a universal law; it describes an idealized population that rarely exists in nature.

How to Read the Results

The calculator outputs the allele frequencies (p and q) and the expected genotype frequencies under Hardy-Weinberg equilibrium. If the observed genotype frequencies (which you can compute from your input counts) closely match the expected ones, the population is said to be in equilibrium for that gene. If they differ substantially, it suggests that one or more evolutionary forces (natural selection, genetic drift, gene flow, mutation, or non-random mating) are acting.

Note that equilibrium does not mean “no evolution” in the sense of allele frequencies staying constant—it means the genotype frequencies are predictable from allele frequencies. A population can be in equilibrium and still have allele frequencies that change over time if the conditions are met (though in practice, allele frequencies remain stable only if all assumptions hold).

Common Mistakes and Limitations

  • Unit mix-ups: Ensure you enter counts of individuals, not percentages or fractions. If you enter 0.4 for AA, the total will be less than 1 and the allele frequencies will be wrong.
  • Using the wrong formula for allele counting: For a diploid species, each individual carries two alleles. The formula uses 2×homozygote count plus heterozygote count, divided by 2×total. Forgetting the factor of 2 leads to incorrect p and q.
  • Assuming equilibrium without testing: The equation gives expected frequencies only if the population is in equilibrium. If you use it to estimate allele frequencies from genotype counts, that part is valid regardless of equilibrium, but the expected genotype frequencies are only valid under equilibrium.
  • Ignoring multiple alleles: This calculator handles two alleles. For more alleles, you need the multinomial expansion (p + q + r)².
  • Small sample sizes: The chi-square test for equilibrium is unreliable with small sample sizes (e.g., total < 50). Use exact tests or collect more data.

The Hardy-Weinberg equation assumes: no mutation, random mating, no natural selection, infinite population size (no genetic drift), and no gene flow. Real populations violate at least one of these, so the equation is a baseline, not a prediction.

Comparison: Hardy-Weinberg vs. Other Population Genetics Tools

The Hardy-Weinberg equation is the simplest population genetics model. Other tools include:

  • Chi-square test: Used to statistically test whether observed genotype frequencies differ from expected Hardy-Weinberg proportions. The calculator gives you the expected frequencies, which you can plug into a chi-square test.
  • F-statistics (FST): Measure population differentiation across subpopulations. Hardy-Weinberg is a prerequisite for some FST calculations.
  • Linkage disequilibrium: Measures non-random association of alleles at different loci. Hardy-Weinberg focuses on a single locus.
  • Coalescent theory: Models the ancestry of alleles backward in time. Hardy-Weinberg is a forward-time model.

For most educational and basic research needs, the Hardy-Weinberg equation is sufficient. For complex evolutionary analysis, you would use software like PLINK or STRUCTURE, which incorporate Hardy-Weinberg tests among many other features.

Frequently Asked Questions

What is the Hardy-Weinberg equation used for?

It is used to calculate expected genotype frequencies from allele frequencies in a population that is not evolving. It also serves as a null hypothesis to test whether evolution is occurring at a specific gene locus.

How do I know if a population is in Hardy-Weinberg equilibrium?

Compare the observed genotype frequencies (counts / total) with the expected frequencies (p², 2pq, q²). If they are very close, the population is in equilibrium. A chi-square test can determine statistical significance; a non-significant p-value (usually > 0.05) indicates no significant deviation.

Can I use the Hardy-Weinberg equation for more than two alleles?

Yes, but the formula expands. For three alleles (p, q, r), the genotype frequencies are p², q², r², 2pq, 2pr, 2qr. The calculator here only handles two alleles; for more, you would need a more general tool.

Why do my observed and expected frequencies differ?

Differences suggest that one or more assumptions are violated: selection, non-random mating, mutation, migration, or genetic drift. It could also be due to sampling error, especially with small sample sizes.

Does the Hardy-Weinberg equation apply to X-linked genes?

Not directly. For X-linked genes, males have one allele (hemizygous) and females have two. The allele frequencies can still be calculated, but the genotype frequencies differ between sexes. The equation requires adjustment for sex-linked inheritance.

What is the difference between allele frequency and genotype frequency?

Allele frequency is the proportion of a specific allele among all alleles in the population. Genotype frequency is the proportion of individuals with a specific genotype. For example, if p = 0.6, then 60% of alleles are A. The genotype frequency of AA is p² = 0.36, meaning 36% of individuals are AA.

Alternatives and Extensions

If you need to analyze more complex scenarios, consider:

  • Chi-square calculator: To test for equilibrium statistically.
  • Multiple allele calculators: For genes with more than two alleles (e.g., ABO blood groups).
  • F-statistics calculators: For population structure analysis.
  • Genetic drift simulators: To model allele frequency changes over generations.

For teaching, the Hardy-Weinberg equation is often paired with simulations like Populus or virtual labs. For research, you would use R packages like pegas or adegenet that include Hardy-Weinberg tests.

Related

Formula used
in a | Count of AA genotype | individuals | 40 | 0
in b | Count of Aa genotype | individuals | 40 | 0
in c | Count of aa genotype | individuals | 20 | 0
out p | Allele frequency of A | - | (a + 0.5*b) / (a + b + c) | 3
out q | Allele frequency of a | - | (c + 0.5*b) / (a + b + c) | 3
out p2 | Expected AA frequency | - | p^2 | 3
out pq | Expected Aa frequency | - | 2*p*q | 3
out q2 | Expected aa frequency | - | 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.