Hardy Weinberg Equilibrium Calculator
- Expected Aa frequency
- Result
- Expected aa frequency
- Result
- Chi-square statistic
- Result
The Hardy-Weinberg equilibrium calculator computes expected genotype frequencies (p², 2pq, q²) from allele frequencies and checks if observed genotype counts deviate from those expectations. You enter allele frequencies or genotype counts, and you get the expected frequencies, the chi-square statistic, and a p-value indicating whether the population is in equilibrium.
Formula
The Hardy-Weinberg principle states that in a large, randomly mating population with no evolutionary forces acting, allele and genotype frequencies remain constant across generations. For a gene with two alleles, A and a, where p is the frequency of allele A and q is the frequency of allele a (p + q = 1), the expected genotype frequencies are:
- AA = p²
- Aa = 2pq
- aa = q²
These are derived from the binomial expansion (p + q)². The chi-square statistic tests whether observed genotype counts differ from these expectations:
χ² = Σ (observed – expected)² / expected
where expected counts are p² × N, 2pq × N, and q² × N, with N being the total number of individuals. The degrees of freedom for this test are 1 (since there are three genotype categories but two independent allele frequencies estimated from the data).
Worked Example
Using the default values from the calculator: p = 0.6, q = 0.4, N = 100.
- Calculate expected genotype frequencies:
- AA = p² = 0.6² = 0.36
- Aa = 2pq = 2 × 0.6 × 0.4 = 0.48
- aa = q² = 0.4² = 0.16
- Convert to expected counts (multiply by N = 100):
- Expected AA = 0.36 × 100 = 36
- Expected Aa = 0.48 × 100 = 48
- Expected aa = 0.16 × 100 = 16
- Since the observed counts are not provided in this simple version, the calculator assumes the observed counts equal the expected counts, giving a chi-square of 0 and a p-value of 1 (perfect equilibrium).
If you had observed genotype counts, you would substitute them into the chi-square formula. For example, if you observed 40 AA, 40 Aa, and 20 aa, the chi-square would be (40-36)²/36 + (40-48)²/48 + (20-16)²/16 = 0.444 + 1.333 + 1.000 = 2.777. With 1 degree of freedom, this gives a p-value around 0.096, indicating no significant deviation from equilibrium.
When to Use This Calculator
This calculator is useful in population genetics to:
- Determine if a population is evolving at a particular locus
- Estimate carrier frequencies for recessive genetic disorders (e.g., if q² is known, q = √q², and carrier frequency = 2pq)
- Check if observed genotype frequencies in a sample match Hardy-Weinberg expectations
- Teach or demonstrate the relationship between allele and genotype frequencies
It is typically applied to a single locus with two alleles. For multiple alleles, the formula extends to (p + q + r + …)², but the chi-square test becomes more complex.
How to Read the Results
The first three outputs are the expected genotype frequencies (AA, Aa, aa) as proportions that sum to 1. The chi-square statistic measures the discrepancy between observed and expected counts. A large chi-square value (and a small p-value, typically < 0.05) suggests the population is not in Hardy-Weinberg equilibrium, indicating that one or more assumptions are violated. A small chi-square (p-value > 0.05) suggests the population is in equilibrium, meaning no significant evolutionary forces are acting at that locus.
Note that this calculator only computes the chi-square statistic; you must look up the p-value from a chi-square distribution table using 1 degree of freedom. Many statistical software packages or online chi-square calculators can do this.
Common Mistakes and Misconceptions
- Using genotype frequencies instead of allele frequencies: The input p and q must be allele frequencies (0 to 1), not genotype frequencies. If you have genotype counts, calculate p = (2×AA + Aa) / (2N) and q = 1 – p.
- Forgetting that p + q = 1: The calculator assumes this; if you enter p and q that don’t sum to 1, the results will be inconsistent.
- Misinterpreting equilibrium as “no evolution”: Hardy-Weinberg equilibrium means no change in allele frequencies, but it does not mean the population is static; it can still have genetic variation.
- Ignoring sample size: Small sample sizes can lead to large sampling error; chi-square tests are less reliable with small N.
- Thinking the test proves equilibrium: A non-significant chi-square does not prove equilibrium; it only fails to reject the null hypothesis.
Limitations and Assumptions
The Hardy-Weinberg equilibrium relies on several assumptions: no mutation, no natural selection, no gene flow, random mating, and an infinitely large population (in practice, a large population with negligible genetic drift). Real populations rarely meet all these conditions, so the equilibrium is a null model rather than a common reality. The chi-square test also assumes independent observations and expected counts of at least 5 in each category; if any expected count is less than 5, the test may be unreliable.
Furthermore, this calculator only handles two alleles. For loci with more than two alleles, you would need a more general approach. Also, the chi-square statistic here is based on the assumption that the observed counts are equal to the expected counts, which is only true if you don’t provide observed data. For a full test, you need to input observed genotype counts separately.
Frequently Asked Questions
How do I calculate allele frequencies from genotype counts?
If you have genotype counts (e.g., AA = 50, Aa = 30, aa = 20), the total number of individuals N = 100. The allele frequency of A is (2×AA + Aa) / (2N) = (100 + 30) / 200 = 0.65. The allele frequency of a is 1 – p = 0.35. Then you can use these p and q values in the calculator.
What does a p-value of 0.05 mean in this context?
A p-value less than 0.05 (the common significance threshold) indicates that the observed genotype frequencies differ significantly from Hardy-Weinberg expectations, suggesting that at least one assumption of the equilibrium is violated. A p-value greater than 0.05 means the deviation is not statistically significant, so the population is considered to be in equilibrium for that locus.
Can this calculator be used for more than two alleles?
No, this calculator is designed for a single locus with two alleles. For multiple alleles, you would need to expand the binomial to a multinomial, and the chi-square test would have more degrees of freedom (number of genotypes – number of alleles).
Why is the chi-square statistic zero in the default example?
Because the calculator does not ask for observed genotype counts, it assumes the observed frequencies match the expected frequencies exactly. This gives a chi-square of 0, meaning no deviation. To get a real test, you need to input observed counts separately or use a different tool that allows that.
What are the units for p and q?
p and q are allele frequencies, which are proportions ranging from 0 to 1. They have no units. The total number of individuals (n) is a count, so it must be a positive integer.
How do I find the p-value from the chi-square statistic?
You can use a chi-square distribution table or an online chi-square calculator. With 1 degree of freedom, a chi-square value of 3.841 corresponds to a p-value of 0.05. Values larger than that give smaller p-values.
Related
Formula used
in p | Frequency of allele A | - | 0.6 | 0 in q | Frequency of allele a | - | 0.4 | 0 in n | Total individuals | - | 100 | 1 out expected_aa | Expected AA frequency | - | p^2 | 4 out expected_aa2 | Expected Aa frequency | - | 2*p*q | 4 out expected_aa3 | Expected aa frequency | - | q^2 | 4 out chi | Chi-square statistic | - | ((p^2*n - p^2*n)^2)/(p^2*n) + ((2*p*q*n - 2*p*q*n)^2)/(2*p*q*n) + ((q^2*n - q^2*n)^2)/(q^2*n) | 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.