ThisCalculator

Biology

Hardy-Weinberg Equilibrium Calculator: Allele & Genotype 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 Equilibrium Calculator: Allele & Genotype Frequencies

This Hardy-Weinberg equilibrium calculator works out the expected genotype frequencies (p², 2pq, q²) and allele frequencies (p, q) from the counts of genotypes you enter, then compares them with the observed values to check whether a population is in equilibrium. You input the number of individuals with each of the three genotypes (e.g., AA, Aa, aa), and the calculator returns the allele frequencies, expected genotype frequencies, and a chi-square test statistic with degrees of freedom. It is a standard tool for introductory population genetics and lets you quickly test whether a population is evolving at a single locus.

Formula

The Hardy-Weinberg principle states that in a large, randomly mating population with no mutation, migration, or selection, allele and genotype frequencies remain constant across generations. For a locus with two alleles, A and a, the relationship is:

p + q = 1

p² + 2pq + q² = 1

Where:

  • p = frequency of the dominant allele (A)
  • q = frequency of the recessive allele (a)
  • p² = expected frequency of homozygous dominant (AA)
  • 2pq = expected frequency of heterozygous (Aa)
  • q² = expected frequency of homozygous recessive (aa)

The allele frequencies are calculated directly from the genotype counts:

p = (2 × count_AA + count_Aa) / (2 × total individuals)

q = 1 – p

The expected genotype counts are then p² × total, 2pq × total, and q² × total. The chi-square statistic compares observed counts to these expected counts to test for deviation from equilibrium.

Worked Example

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

  1. Calculate allele frequencies:

p = (2×50 + 40) / (2×100) = (100 + 40) / 200 = 140/200 = 0.7

q = 1 – 0.7 = 0.3

  1. Calculate expected genotype frequencies:

p² = 0.7² = 0.49

2pq = 2 × 0.7 × 0.3 = 0.42

q² = 0.3² = 0.09

  1. Calculate expected counts (multiply by total 100):

Expected AA = 0.49 × 100 = 49

Expected Aa = 0.42 × 100 = 42

Expected aa = 0.09 × 100 = 9

  1. Compute chi-square:

χ² = (50–49)²/49 + (40–42)²/42 + (10–9)²/9 = 0.0204 + 0.0952 + 0.1111 = 0.2267

The calculator shows p = 0.7, q = 0.3, expected frequencies 0.49, 0.42, 0.09, and chi-square ≈ 0.23. With 1 degree of freedom (3 genotypes – 2 alleles), this small value suggests the population is in equilibrium (no significant deviation).

How to Use the Calculator

Enter the number of individuals with each genotype. The three counts must sum to the total population size. The calculator automatically computes:

  • Allele frequencies (p and q)
  • Expected genotype frequencies under Hardy-Weinberg equilibrium
  • Chi-square statistic for goodness of fit

To interpret the chi-square result, compare it to a critical value from a chi-square distribution with 1 degree of freedom (for two alleles). At the 0.05 significance level, the critical value is 3.841. If your chi-square is larger than that, the population deviates significantly from equilibrium, suggesting evolutionary forces at play. If smaller, the population is consistent with equilibrium.

When to Use Hardy-Weinberg

This calculation is most useful in population genetics studies, conservation biology, and evolutionary biology. It is used to:

  • Detect whether a population is evolving at a specific locus
  • Estimate carrier frequencies for recessive genetic disorders
  • Check genotype data for errors (e.g., in forensic or ecological studies)
  • Test assumptions in breeding and conservation programs

For example, if you know the frequency of a recessive disease (q²), you can calculate the carrier frequency (2pq) using this principle. However, the Hardy-Weinberg model assumes no selection, no mutation, no migration, random mating, and infinite population size – conditions rarely met in reality, so deviations are common and informative.

Common Mistakes and Limitations

One frequent error is mixing up allele frequencies with genotype frequencies. Remember p and q are allele frequencies, while p², 2pq, and q² are genotype frequencies. Another mistake is using the wrong total: the total must be the number of individuals, not the number of alleles. Also, ensure your genotype counts are mutually exclusive – each individual belongs to exactly one genotype.

The chi-square test assumes expected counts are not too small (typically ≥5). If any expected count is below 5, the test may not be valid; consider using Fisher’s exact test instead. Also, the test has 1 degree of freedom for two alleles, but if you have multiple alleles, degrees of freedom change accordingly.

The Hardy-Weinberg equilibrium is a null model, not a real population state. Real populations often deviate due to natural selection, genetic drift, non-random mating, or gene flow. A significant chi-square indicates that at least one assumption is violated, but it doesn’t tell you which one. Further analysis is needed to identify the cause.

Comparisons with Other Methods

For more complex scenarios, other tools are used:

  • F-statistics (Fst): Measure population differentiation between subpopulations, not just deviation from equilibrium.
  • Bayesian methods: Estimate allele frequencies with prior distributions, useful for small samples or complex models.
  • Exact tests: Like Fisher’s exact test, more accurate for small sample sizes or rare alleles.
  • Linkage disequilibrium analysis: Examines associations between alleles at different loci, not just single-locus equilibrium.

For a single locus with two alleles, the chi-square test is simple and sufficient. For multiple alleles or small samples, consider exact tests or simulation-based methods.

Frequently Asked Questions

What does a significant chi-square value mean?

If the chi-square statistic exceeds the critical value (e.g., 3.841 for α=0.05, df=1), it means the observed genotype frequencies differ significantly from what Hardy-Weinberg equilibrium predicts. This suggests that one or more evolutionary forces (selection, mutation, migration, genetic drift, non-random mating) are affecting the locus.

Can I use this calculator for multiple alleles?

No, this calculator is designed for two alleles only. For multiple alleles, you would need to extend the formulas: for three alleles, the expected genotype frequencies are p², 2pq, 2pr, q², 2qr, r², and the degrees of freedom change. This calculator does not handle that case.

What if my observed genotype counts are all zero for one genotype?

If a genotype count is zero, the calculator still works, but the expected count for that genotype may also be very small, leading to an unreliable chi-square. In such cases, consider grouping rare genotypes or using an exact test.

How do I interpret p and q?

p is the frequency of the A allele in the population, and q is the frequency of the a allele. They always sum to 1. For example, p=0.7 means 70% of all alleles at that locus are A. These are population-level frequencies, not individual probabilities.

Is Hardy-Weinberg equilibrium the same as random mating?

No, random mating is one of the assumptions of Hardy-Weinberg equilibrium, but equilibrium also requires no selection, mutation, migration, and infinite population size. Random mating alone does not guarantee equilibrium if other forces are acting.

Can I use this for a haploid organism?

No, the Hardy-Weinberg principle applies to diploid organisms with two copies of each gene. For haploids, allele frequencies are simply the genotype frequencies, and there is no heterozygote class.

Practical Example: Testing a Population

Suppose you are studying a population of 200 plants with genotypes: 80 TT, 100 Tt, 20 tt. Enter 80, 100, 20 into the calculator. The allele frequency of T is (2×80 + 100)/(2×200) = 260/400 = 0.65, so t = 0.35. Expected genotype frequencies: TT = 0.4225, Tt = 0.455, tt = 0.1225. Expected counts: 84.5, 91, 24.5. Chi-square = (80–84.5)²/84.5 + (100–91)²/91 + (20–24.5)²/24.5 ≈ 0.24 + 0.89 + 0.83 = 1.96, which is less than 3.841, so the population is in equilibrium. This indicates no significant evolutionary change at this locus.

Related

Formula used
in a | Count of AA genotype | individuals | 50 | 0
in b | Count of Aa genotype | individuals | 40 | 0
in c | Count of aa genotype | individuals | 10 | 0
out p | Allele frequency of A | - | (2*a + b) / (2*(a + b + c)) | 4
out q | Allele frequency of a | - | 1 - p | 4
out exp_aa | Expected AA frequency | - | p^2 | 4
out exp_ab | Expected Aa frequency | - | 2*p*q | 4
out exp_bb | Expected aa frequency | - | q^2 | 4
out chi | Chi-square statistic | - | ((a - exp_aa*(a+b+c))^2)/(exp_aa*(a+b+c)) + ((b - exp_ab*(a+b+c))^2)/(exp_ab*(a+b+c)) + ((c - exp_bb*(a+b+c))^2)/(exp_bb*(a+b+c)) | 4

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.