Hardy-Weinberg Calculator
Calculate allele frequencies, genotype frequencies, and test for Hardy-Weinberg equilibrium in populations.
Input Data
Hardy-Weinberg Equation
p² + 2pq + q² = 1
p + q = 1 (allele frequencies sum to 1)
Allele Frequencies
Genotype Frequencies
Assumptions
- • No natural selection
- • No genetic drift (large population)
- • No gene flow (migration)
- • No mutation
- • Random mating
Hardy-Weinberg Calculator Overview
The Hardy-Weinberg calculator is a population genetics tool that converts allele frequencies into expected genotype frequencies and tests whether a real population matches the predictions of the Hardy-Weinberg principle. Named after mathematician G. H. Hardy and physician Wilhelm Weinberg, who independently described it in 1908, this principle is the foundational null model of evolutionary genetics. It states that in a large, randomly mating population free from selection, mutation, migration, and genetic drift, allele and genotype frequencies stay constant from one generation to the next.
This Hardy-Weinberg equilibrium calculator works in two modes. In allele frequency mode you enter the dominant allele frequency p along with a population size, and the calculator returns the recessive frequency q, the three genotype frequencies, and the expected number of individuals in each genotype class. In observed counts mode you enter the actual number of homozygous dominant (AA), heterozygous (Aa), and homozygous recessive (aa) individuals; the tool back-calculates the allele frequencies from those genotype counts and then runs a chi-square goodness-of-fit test to decide whether the population is in equilibrium.
Population geneticists, conservation biologists, genetic counselors, and students use the Hardy-Weinberg calculator to estimate carrier frequencies for recessive diseases, to flag populations that may be experiencing selection or inbreeding, and to teach the core mathematics of microevolution. Because the model is a baseline expectation, any statistically significant departure from Hardy-Weinberg proportions is itself a useful signal that one of the model's assumptions has been violated.
Hardy-Weinberg Equation and Formula
The Hardy-Weinberg principle rests on two linked equations. The first states that the two allele frequencies must sum to one, and the second expands the genotype frequencies as the square of that sum. For a single gene with two alleles, a dominant allele A at frequency p and a recessive allele a at frequency q, the relationships are:
- p + q = 1 — the allele frequencies add up to the whole gene pool.
- p² + 2pq + q² = 1 — the three genotype frequencies add up to one.
Here p² is the expected frequency of the homozygous dominant genotype (AA), 2pq is the frequency of the heterozygous genotype (Aa), and q² is the frequency of the homozygous recessive genotype (aa). Multiplying each frequency by the population size N gives the expected count of individuals in that class. When you supply observed genotype counts instead, the calculator first recovers the allele frequencies directly from the genotypes using p = (2·AA + Aa) / (2N) and q = (2·aa + Aa) / (2N), where N is the total number of individuals counted. Each individual carries two alleles, so the denominator 2N counts the full diploid gene pool.
Hardy-Weinberg Equilibrium
Where:
- p= Frequency of the dominant allele A
- q= Frequency of the recessive allele a (q = 1 − p)
- p²= Expected frequency of homozygous dominant genotype AA
- 2pq= Expected frequency of heterozygous genotype Aa
- q²= Expected frequency of homozygous recessive genotype aa
- N= Total number of individuals in the population sample
- AA, Aa, aa= Observed counts of each genotype
How to Use the Hardy-Weinberg Calculator
Begin by choosing an input mode that matches the data you have. Select Allele Frequency when you already know p, the frequency of the dominant allele, perhaps from a textbook problem or a published estimate. Enter a value between 0 and 1, optionally use the quick-pick buttons (0.1, 0.3, 0.5, 0.7, 0.9), and set a population size such as 1000. The calculator immediately computes q = 1 − p, the three genotype frequencies p², 2pq, and q², the corresponding percentages, and the expected count of individuals in each genotype class rounded to the nearest whole person.
Choose Observed Counts when you have surveyed a real population and counted how many individuals carry each genotype. Enter the number of AA (homozygous dominant), Aa (heterozygous), and aa (homozygous recessive) individuals. The Hardy-Weinberg calculator derives the allele frequencies from those genotype counts, computes the expected genotype numbers under equilibrium, and then performs a chi-square goodness-of-fit test with one degree of freedom. The result panel reports the chi-square statistic, an approximate p-value range, and a clear verdict on whether the population is in Hardy-Weinberg equilibrium at the 0.05 significance level.
Read the verdict in context. A chi-square value below the critical threshold of 3.841 means the observed genotype counts do not differ significantly from the equilibrium expectation, so you cannot reject the null model. A larger chi-square flags a meaningful departure and suggests that selection, non-random mating, inbreeding, migration, or genotyping error may be at work.
Interpreting Allele and Genotype Frequencies
The output of a Hardy-Weinberg calculation has two layers. The first layer is the pair of allele frequencies, p and q, which describe the makeup of the entire gene pool. The second layer is the set of genotype frequencies, which describe how those alleles are packaged into individuals under random mating. A useful sanity check is that the three genotype frequencies always sum to 1.0 and the two allele frequencies always sum to 1.0; if they do not, an input is out of range.
The heterozygote frequency 2pq is maximized when p = q = 0.5, where it reaches 0.50, meaning half the population is heterozygous. As an allele becomes rare, most copies of it hide inside heterozygous carriers rather than appearing in affected homozygotes. This is why the calculator is so useful in human genetics: for a rare recessive disease, the carrier frequency 2pq vastly exceeds the affected frequency q².
The chi-square output describes goodness of fit, not biological cause. A population in equilibrium is consistent with the model's assumptions but does not prove they all hold, because the test has limited power with small samples. Conversely, a population that fails the test tells you the assumptions are violated somewhere, but you must combine the result with additional data to identify whether selection, drift, inbreeding, gene flow, or assortative mating is responsible.
Assumptions Behind Hardy-Weinberg Equilibrium
The Hardy-Weinberg model is an idealization, and its five assumptions define exactly what must be true for allele frequencies to stay constant across generations. Understanding them is essential to interpreting the calculator correctly.
- No natural selection. Every genotype must have equal survival and reproductive success. Differential fitness changes allele frequencies and breaks equilibrium.
- No genetic drift. The population must be effectively infinite so that random sampling of gametes does not shift frequencies. Small populations drift noticeably from generation to generation.
- No gene flow. No migration of individuals into or out of the population, since immigrants can introduce alleles at different frequencies.
- No mutation. New alleles must not be created and existing alleles must not change identity during the interval examined.
- Random mating. Individuals must pair without regard to genotype at the locus. Inbreeding and assortative mating change genotype proportions even when allele frequencies are unchanged.
Real populations rarely satisfy all five conditions perfectly, which is precisely why the model is valuable. By comparing observed data against the equilibrium prediction, biologists detect which evolutionary forces are acting. A locus that consistently deviates from Hardy-Weinberg proportions in genome-wide studies is often flagged for genotyping error, while a deficiency of heterozygotes across many loci is a classic signature of inbreeding or population structure.
Applications in Genetics and Medicine
The Hardy-Weinberg calculator has practical reach far beyond the classroom. In genetic counseling, the equation estimates carrier frequencies for autosomal recessive conditions such as cystic fibrosis, sickle cell anemia, and Tay-Sachs disease. If the incidence of an affected genotype (q²) is known from newborn screening, the recessive allele frequency q is its square root, and the carrier frequency 2pq follows immediately, informing risk estimates for prospective parents.
In conservation biology, deviations from equilibrium help reveal inbreeding and reduced effective population size in endangered species, guiding breeding programs that aim to preserve genetic diversity. In forensic genetics and population studies, Hardy-Weinberg testing validates that genetic markers behave as expected before they are used to compute match probabilities. Modern genome-wide association studies routinely apply Hardy-Weinberg filtering as a quality-control step, removing variants whose genotype distributions deviate strongly from expectation because such deviation often signals a technical artifact rather than true biology.
For students, the Hardy-Weinberg calculator turns abstract algebra into intuition. By adjusting the dominant allele frequency and watching the genotype percentages respond, learners see how rare alleles persist in heterozygous carriers and how the heterozygote class peaks at intermediate frequencies. This hands-on exploration reinforces why the principle remains the cornerstone null hypothesis of evolutionary and medical genetics.
Worked Examples
Genotype frequencies from a known allele frequency
Problem:
A population has a dominant allele frequency p = 0.6 and a population size of 1000. Find the recessive allele frequency, the three genotype frequencies, and the expected number of individuals in each genotype.
Solution Steps:
- 1Compute the recessive allele frequency: q = 1 − p = 1 − 0.6 = 0.4.
- 2Compute genotype frequencies: AA = p² = 0.6² = 0.36; Aa = 2pq = 2 × 0.6 × 0.4 = 0.48; aa = q² = 0.4² = 0.16.
- 3Confirm they sum to one: 0.36 + 0.48 + 0.16 = 1.00.
- 4Multiply by N = 1000 for expected counts: AA = 360, Aa = 480, aa = 160 individuals.
Result:
p = 0.6, q = 0.4; AA = 36% (360), Aa = 48% (480), aa = 16% (160).
Allele frequencies from observed genotype counts
Problem:
A sample of 1000 individuals contains 360 AA, 480 Aa, and 160 aa. Calculate the allele frequencies p and q directly from these genotype counts.
Solution Steps:
- 1Find the total: N = 360 + 480 + 160 = 1000 individuals (2000 allele copies).
- 2Compute p = (2 × AA + Aa) / (2N) = (2 × 360 + 480) / 2000 = (720 + 480) / 2000 = 1200 / 2000 = 0.6.
- 3Compute q = (2 × aa + Aa) / (2N) = (2 × 160 + 480) / 2000 = (320 + 480) / 2000 = 800 / 2000 = 0.4.
- 4Check that p + q = 0.6 + 0.4 = 1.00, confirming the gene pool is fully accounted for.
Result:
p = 0.6 and q = 0.4, identical to the equilibrium expectation for these counts.
Chi-square test for Hardy-Weinberg equilibrium
Problem:
Using the observed counts 360 AA, 480 Aa, 160 aa (p = 0.6, q = 0.4), test whether the population is in Hardy-Weinberg equilibrium at the 0.05 level.
Solution Steps:
- 1Expected counts under equilibrium: AA = p²N = 0.36 × 1000 = 360; Aa = 2pqN = 0.48 × 1000 = 480; aa = q²N = 0.16 × 1000 = 160.
- 2Each observed count equals its expected count, so every (observed − expected)² term is 0.
- 3Chi-square = (360−360)²/360 + (480−480)²/480 + (160−160)²/160 = 0 + 0 + 0 = 0.
- 4Compare 0 with the critical value 3.841 for 1 degree of freedom; since 0 < 3.841, the deviation is not significant.
Result:
Chi-square = 0.0000 (p > 0.5); the population is in Hardy-Weinberg equilibrium.
Carrier frequency for a rare recessive disease
Problem:
An autosomal recessive disease affects 1 in 10,000 newborns (q² = 0.0001). Estimate the recessive allele frequency and the carrier frequency in the population.
Solution Steps:
- 1Find q as the square root of the affected frequency: q = √0.0001 = 0.01.
- 2Find the dominant allele frequency: p = 1 − q = 1 − 0.01 = 0.99.
- 3Compute the carrier (heterozygote) frequency: 2pq = 2 × 0.99 × 0.01 = 0.0198.
- 4Express as a proportion: about 0.0198, or roughly 1 in 51 individuals, are unaffected carriers.
Result:
q = 0.01, p = 0.99; carrier frequency 2pq ≈ 0.0198 (about 2% of the population).
Tips & Best Practices
- ✓Use allele frequency mode for textbook problems and observed counts mode when you have real survey data.
- ✓Always confirm that p + q = 1 and that the three genotype frequencies sum to 1.0 as a quick sanity check.
- ✓For a rare recessive disease, estimate q as the square root of the affected frequency q², then read off carrier frequency 2pq.
- ✓Remember the heterozygote frequency 2pq peaks at 0.50 when p = q = 0.5; rare alleles hide mostly in heterozygotes.
- ✓A chi-square below 3.841 (df = 1) means you cannot reject equilibrium at the 0.05 significance level.
- ✓Treat a failed equilibrium test as a clue, not a diagnosis; combine it with biological context to identify the cause.
- ✓Larger sample sizes give the chi-square test more power to detect real departures from equilibrium.
- ✓Check for genotyping or data-entry errors before concluding that a deviation reflects a true evolutionary force.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-05
Help us improve!
How would you rate the Hardy-Weinberg Calculator?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Standard Mathematical References
by Various