How to use the Hardy-Weinberg Calculator
- Choose what you know: genotype counts from a sample, or one frequency such as p, q, p², 2pq, q² or the recessive phenotype frequency.
- Enter the numbers. Frequencies can be typed as a decimal, a percentage, a fraction or "1 in N"; add a population size to get expected counts.
- Read p, q and the genotype frequencies p², 2pq and q² with expected counts in the table.
- With counts, check the χ² test (df = 1): a p-value below 0.05 means the sample departs significantly from Hardy-Weinberg equilibrium.
- Open the step-by-step working to copy the method into your notes or exam answer.
The Hardy-Weinberg principle
The Hardy-Weinberg principle states that in a large, randomly mating population with no evolutionary forces acting, allele and genotype frequencies stay constant from generation to generation. The population is then in Hardy-Weinberg equilibrium (HWE), also called genetic equilibrium. It was described independently by G. H. Hardy and Wilhelm Weinberg in 1908.
For one gene with two alleles, A (frequency p) and a (frequency q):
The equilibrium assumes a large population, random mating, and no mutation, migration or natural selection.
Class 12 NCERT context
In the NCERT Class 12 Biology chapter Evolution, the Hardy-Weinberg principle is used to explain what evolution means in genetic terms. The total genes and their alleles in a population form the gene pool, and the sum of all allelic frequencies is 1. NCERT writes the principle as p² + 2pq + q² = 1, the binomial expansion of (p + q)². When the measured frequencies differ from the expected values, the difference indicates the extent of evolutionary change. NCERT lists five factors that disturb the equilibrium:
- Gene migration or gene flow – alleles enter or leave with migrating individuals.
- Genetic drift – chance changes in frequency, strongest in small populations; the founder effect is one example.
- Mutation – creates new alleles.
- Genetic recombination – during gametogenesis.
- Natural selection – some genotypes leave more offspring.
The notation (p for the dominant allele, q for the recessive allele) and the reasoning on this page follow NCERT conventions.
Worked example 1: from the recessive phenotype
A recessive condition affects 1 in 10,000 people. Only aa individuals show it, so q² = 0.0001.
- q = √0.0001 = 0.01; p = 1 − 0.01 = 0.99.
- Carriers: 2pq = 2 × 0.99 × 0.01 = 0.0198, about 1 in 50.5 people.
The striking point: although only 1 in 10,000 is affected, roughly 2% of people carry the allele, so most copies of a rare recessive allele are hidden in heterozygotes.
Worked example 2: testing a sample with χ²
A sample of 1,000 individuals contains 380 AA, 440 Aa and 180 aa.
- p = (2 × 380 + 440) ÷ 2,000 = 1,200 ÷ 2,000 = 0.6; q = 0.4.
- Expected: AA = 1,000 × 0.36 = 360, Aa = 1,000 × 0.48 = 480, aa = 1,000 × 0.16 = 160.
- χ² = (380 − 360)² ÷ 360 + (440 − 480)² ÷ 480 + (180 − 160)² ÷ 160 = 1.111 + 3.333 + 2.5 = 6.944.
- df = 3 classes − 1 − 1 estimated parameter = 1. The critical value at 5% is 3.841, and the exact p-value is about 0.0084.
Because 6.944 > 3.841, the sample deviates significantly from HWE: there are fewer heterozygotes than expected, which can point to inbreeding, population substructure or genotyping error.
Interpreting the χ² test
| χ² (df = 1) | p-value | Conclusion at 5% |
|---|---|---|
| ≤ 3.841 | ≥ 0.05 | No significant deviation from HWE |
| > 3.841 | < 0.05 | Significant deviation from HWE |
| > 6.635 | < 0.01 | Significant at the 1% level |
This calculator computes the p-value exactly from the χ² distribution (the regularized incomplete gamma function), not from a lookup table. If any expected count is below 5 the χ² approximation becomes unreliable and an exact test is preferred.
Common mistakes
- Taking q from the carrier frequency. Start from the homozygous recessive (aa) frequency, which equals q². The dominant phenotype is p² + 2pq, not p².
- Forgetting the square root. If q² = 0.16, then q = 0.4, not 0.16.
- Counting individuals instead of alleles. Each individual carries two alleles, so divide by 2N.
- Using df = 2. One degree is lost because p is estimated from the same data.
Exam tips (Class 12 and NEET)
- Write both equations first: p + q = 1 and p² + 2pq + q² = 1.
- 2pq is largest (0.5) when p = q = 0.5.
- Learn the five disturbing factors in NCERT's order; they are frequently asked as one-mark questions.
For crosses between two parents, use the Punnett square calculator.
Frequently asked questions
What is the Hardy-Weinberg equation?
How do you find q from the recessive phenotype?
What are the five factors that affect Hardy-Weinberg equilibrium?
How do you test if a population is in Hardy-Weinberg equilibrium?
Why is the degree of freedom 1 in the Hardy-Weinberg chi-square test?
What does 2pq represent?
Last reviewed November 2026. Results are estimates for information only — see our disclaimer.