Hardy-Weinberg calculator
A Hardy-Weinberg calculator works out allele and genotype frequencies in a population from one known value. For a gene with two alleles, p + q = 1 and p² + 2pq + q² = 1, where p and q are the allele frequencies and p², 2pq and q² are the genotype frequencies. Our Hardy-Weinberg Calculator starts from whatever you know, a phenotype share, an allele frequency, carriers or genotype counts, and gives all five frequencies with the working.
It opens on a recessive condition seen in 0.0004 of the population, 1 in 2,500, which works out to a carrier in about every 25.5 people.
Hardy-Weinberg Calculator
Find allele and genotype frequencies in a population
How to use the Hardy-Weinberg calculator
- Under Calculate, choose what you know: q² (the share with the recessive phenotype), p² + 2pq (the share with the dominant phenotype), p, q, 2pq (the heterozygote share), 1 in N, or Counts of each genotype.
- Type the value as a decimal from 0 to 1: 16% is 0.16. For 1 in N, type N, such as 2500. For Counts, type the number of AA, Aa and aa individuals.
- Read q, then p, p², 2pq and q² together, with the carriers as roughly 1 in N.
- Follow the working, which finds q first, then everything else from it.
With genotype counts, the calculator counts the alleles directly, works out how many of each genotype you would expect at equilibrium, and runs a chi-squared test of the fit. A graph shows 2pq against q, with your q marked. Practice and help sets Hardy-Weinberg questions with worked answers.
The Hardy-Weinberg equation
| Symbol | Meaning |
|---|---|
| p | Frequency of the dominant allele, A |
| q | Frequency of the recessive allele, a |
| p² | Frequency of homozygous dominant individuals, AA |
| 2pq | Frequency of heterozygous individuals (carriers), Aa |
| q² | Frequency of homozygous recessive individuals, aa |
Only the aa individuals show a recessive phenotype, so the share with that phenotype is q². That is almost always the way in: take the square root to get q, then p = 1 − q. The dominant phenotype includes both AA and Aa, so its share is p² + 2pq = 1 − q².
Worked examples you can check in the calculator
Example 1: from a recessive condition
A recessive condition affects 1 in 2,500 people. What share are carriers? q² = 1/2500 = 0.0004, so:
About 3.9% of people are carriers, roughly 1 in 25.5. This is the calculator's opening example; choose 1 in N and type 2500 to get the same. Carriers far outnumber affected people for a rare recessive condition, here about 98 to 1.
Example 2: from the dominant phenotype
In a population of plants, 84% have purple flowers, the dominant phenotype. So 16% have white flowers: q² = 0.16.
Choose p² + 2pq and type 0.84. The calculator gives q = 0.4 and the genotype frequencies 0.36, 0.48 and 0.16. Of the purple plants, 0.48 ÷ 0.84 = 57% are heterozygous.
Here x is the recessive allele frequency q and y is the heterozygote frequency 2pq. It peaks at 0.5 when both alleles are equally common, which is why the calculator will not accept a 2pq above 0.5.
Example 3: from genotype counts
A sample has 260 AA, 205 Aa and 35 aa individuals, 500 in all. Count the alleles: each AA has two A, each Aa has one.
Choose Counts and type 260, 205 and 35. The calculator gives p = 0.725 and q = 0.275, and the counts expected at equilibrium, 262.8, 199.4 and 37.81.
Test your reading:
Testing for Hardy-Weinberg equilibrium with chi-squared
Genotype counts let you test whether a population is in equilibrium. Compare the observed counts with the expected ones using χ² = Σ(O − E)²/E, with 1 degree of freedom: two alleles give 3 genotype classes, minus 1, minus 1 more for estimating p from the data. The critical value at the 5% level is 3.841.
| Genotype | Observed | Expected | (O − E)²/E |
|---|---|---|---|
| AA | 380 | 360 | 1.111 |
| Aa | 440 | 480 | 3.333 |
| aa | 180 | 160 | 2.5 |
For 380 AA, 440 Aa and 180 aa, p = 0.6, and χ² = 6.944. That is above 3.841, so the population is not in Hardy-Weinberg equilibrium: there are fewer heterozygotes than expected. The calculator gives 6.944 and says "not in equilibrium". Example 3's sample gives χ² = 0.398, which fits.
The Hardy-Weinberg assumptions
The equations hold only for an idealised population that is not evolving at this gene:
- Random mating, with no choosing of partners by genotype.
- No natural selection on the gene.
- No mutation creating new alleles.
- No migration in or out.
- A very large population, so chance changes (genetic drift) are negligible.
When a population is out of equilibrium, as in the chi-squared example, one or more of these is being broken, and the allele frequencies may be changing: the population may be evolving.
Common mistakes
- Using the dominant phenotype share as p². The dominant phenotype is p² + 2pq. Start from the recessive phenotype, q², instead.
- Forgetting the square root. If 16% are aa, q is 0.4, not 0.16.
- Forgetting the 2 in 2pq. There are two ways to be heterozygous: A from one parent and a from the other, or the reverse.
- Typing a percentage. The calculator wants a decimal from 0 to 1: 4% is 0.04.
- Using 2 degrees of freedom. The Hardy-Weinberg chi-squared test with two alleles has 1, because p was estimated from the data.
Practise genetics in a short timed paper
Hardy-Weinberg questions come up in AP Biology practice, and in A-level Biology: Year 2 in the UK. Each daily paper is a short timed paper of 8 questions worth 25 to 35 marks, and the papers mix topics. The Genetics and DNA course covers alleles and genotypes, and the Punnett square calculator guide covers single crosses.
Common questions
What is the Hardy-Weinberg equation?
How do you find q in Hardy-Weinberg?
How do you calculate carrier frequency?
How do you find allele frequencies from genotype counts?
How do you test for Hardy-Weinberg equilibrium?
What are the five Hardy-Weinberg conditions?
Revision cards
Say the answer first, then flip the card to check it.
Where to go next
- Solve it
Hardy-Weinberg Calculator
Find allele and genotype frequencies in a population
Open the tool - Learn it
Genetics & DNA
From Mendel to CRISPR: how traits are inherited and genomes are edited
Start the course - Test it
AP Biology
A new exam-style paper every day, with instant marking and a mark scheme
Start today's paper