What this calculator does
Find out how common each version of a gene is in a population, and what mix of genotypes to expect. Each version of a gene is called an allele, and a genotype is the pair of alleles an individual carries. The Hardy-Weinberg principle describes a population that isn't evolving at one gene. Say mating is random, with no selection, mutation, migration or drift (random change from chance). Then the allele frequencies stay the same from one generation to the next. The genotype frequencies settle at p², 2pq and q². That makes it the standard starting point for asking whether something is changing a population.
This calculator works in two directions. You can start from counts of AA, Aa and aa individuals. It then estimates the allele frequencies and predicts the genotype frequencies that balance (equilibrium) would give. It can also run a chi-square test, a standard check of how well the counts fit. Or you can start from the share of individuals showing a recessive trait (one that only shows with two copies). It then works back to the allele frequencies and the expected share of carriers, who have one copy each.
Where it's used
Why this math matters outside the classroom:
- Carrier frequency. Genetics students find that if 1 in 10,000 people show a recessive trait, q = 0.01 and about 2% of people are carriers.
- Conservation. Conservation biologists compare observed and expected genotype counts in small populations to spot inbreeding.
- Detecting evolution. Biology classes use the equilibrium as a baseline, so a shift in allele frequency between generations signals evolution.
- Class data. A sample of 36 AA, 48 Aa and 16 aa gives p = (72 + 48) ÷ 200 = 0.6 and q = 0.4.
- Crop breeding. Plant breeders track how often a desired allele appears in a seed population as they select across generations.
Grade level and standards: Grades 11–12; Common Core State Standards for Mathematics HSS.CP.A.2. © Copyright 2010. National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.
How to use it
- Choose whether you have genotype counts, or only the share of individuals showing the recessive trait.
- For counts, enter the number of AA, Aa and aa individuals. Leave the chi-square box ticked to test the fit.
- For the recessive route, enter the percentage of the population showing the recessive trait.
- Read p and q and the expected genotype frequencies. If you ran the test, you'll also see the chi-square value and the p-value.
What the inputs mean
- AA (homozygous dominant) count
- Whole numbers of individuals, not percentages. You need to be able to tell all three genotypes apart. That's true for codominant markers (where both alleles show) and DNA tests. It isn't true when Aa individuals look the same as AA ones.
- Run a chi-square test against Hardy-Weinberg expectations
- Compares the observed counts with N·p², N·2pq and N·q², where N is the number of individuals. It has 1 degree of freedom (the number of values free to vary), because p is estimated from the same data.
- Share showing the recessive trait (q²)
- The share of individuals showing the recessive trait. It equals q² only if the population is in equilibrium. Use decimals for rare traits: 1 in 10,000 is 0.01%.
Formula and method
p = (2·AA + Aa) ÷ (2N) q = (2·aa + Aa) ÷ (2N) p + q = 1 expected frequencies: AA = p², Aa = 2pq, aa = q² χ² = Σ (observed − expected)² ÷ expected, df = 1 recessive route: q = √(q²), p = 1 − q
p is the share of A alleles and q is the share of a alleles. AA, Aa and aa are the counts of each genotype, and N is the total number of individuals. Each individual carries two copies of the gene, so N individuals carry 2N alleles. AA individuals add two A alleles each, and Aa individuals (heterozygotes) add one. That gives the formula for p, and the same logic gives q.
Suppose egg and sperm cells (gametes) combine at random. Then the chance of getting A twice is p × p, and a twice is q × q. The chance of one of each is p × q + q × p = 2pq. Multiplying these frequencies by N gives the expected counts.
χ² is the chi-square value, Σ means "add up over the three genotypes", and df is the degrees of freedom. The chi-square value measures how far the observed counts are from the expected ones. The p-value is the chance of a value at least that large if the population really were in equilibrium. A small p-value (below 0.05 here) suggests a real departure.
Sometimes you can only spot the recessive trait. Then its frequency is taken as q², and the square root (√) gives q. This step assumes the population is already in equilibrium, so it can't be used to test equilibrium.
Worked example
A sample of 1,000 individuals contains 298 AA, 489 Aa and 213 aa. Are they consistent with Hardy-Weinberg equilibrium?
- N = 298 + 489 + 213 = 1,000.
- p = (2 × 298 + 489) ÷ 2,000 = 0.5425 and q = (2 × 213 + 489) ÷ 2,000 = 0.4575.
- Expected frequencies: p² ≈ 0.2943, 2pq ≈ 0.4964 and q² ≈ 0.2093, or about 294.31, 496.39 and 209.31 individuals.
- χ² = 3.69375² ÷ 294.30625 + 7.3875² ÷ 496.3875 + 3.69375² ÷ 209.30625 ≈ 0.2215.
- With 1 degree of freedom the p-value is about 0.6379.
Result: p = 0.5425 and q = 0.4575. The p-value of about 0.638 is well above 0.05. So there's no significant departure from what Hardy-Weinberg predicts.
Understanding the result
A test that isn't significant doesn't prove the population is in equilibrium. It only means this sample gives no strong evidence against it. Small samples have little power to detect departures.
A significant result says the genotype frequencies don't match random mating, but it doesn't say why. Common causes include inbreeding or a population split into groups (often seen as too few Aa individuals). Others are selection, recent migration, or mistakes in how genotypes were recorded.
In the recessive route, 2pq is the expected share of carriers, who have one copy of the recessive allele. For rare recessive traits this is far larger than q². That's why most copies of a rare recessive allele are carried by people or animals who don't show the trait.
Assumptions and limitations
- One gene with two alleles, in a diploid organism (one with two copies of each gene).
- Random mating and no selection, mutation, migration or genetic drift in the generation considered.
- In counts mode, every genotype can be identified, and the sample is representative of the population.
- In the recessive route, the population is assumed to be in equilibrium, and the recessive trait is fully recessive.
- Genes with three or more alleles, and sex-linked genes, need different formulas.
- The chi-square shortcut is unreliable when any expected count is below about 5. An exact test is better for small samples.
- The test uses a fixed 5% significance level. Choose your own cutoff if your field uses another.
- Results describe populations, not the risk for any individual, and are not a substitute for genetic counselling.
Frequently asked questions
Why does the chi-square test have only 1 degree of freedom?
There are three genotype groups. Once the total is fixed, that would leave 2 degrees of freedom. One more is lost because p is estimated from the same counts used in the test, leaving 1.
Can I estimate carrier frequency from how common a recessive condition is?
Yes, using the recessive route, as long as you're willing to assume equilibrium. If 0.04% of a population shows a recessive trait, q = 0.02 and about 3.92% are carriers, roughly 1 in 25.5.
Why are p and q based on alleles rather than individuals?
Because parents pass genes on one allele at a time, in egg and sperm cells. Counting alleles, two per individual, tracks what actually goes into the next generation.
What if my sample has only one allele?
Then p or q is zero, and every individual has the same genotype. In that case the population matches equilibrium automatically, with nothing to test. The calculator shows the frequencies but skips the chi-square test.
How this calculator is checked
Method: Hardy-Weinberg principle: allele counting p = (2·AA + Aa)/2N; expected genotype frequencies p², 2pq, q²; Pearson chi-square goodness of fit with 1 degree of freedom, p-value from the regularized incomplete gamma function. The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.
Embed this calculator
Put this Hardy-Weinberg Calculator on your own website or blog for free. Paste this code where you want it to appear: