Uni-Sine
Biology
+25XP
BiologyGenetics and inheritance

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.

Try it

Hardy-Weinberg Calculator

Find allele and genotype frequencies in a population

Go to its page

How to use the Hardy-Weinberg calculator

  1. 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.
  2. 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.
  3. Read q, then p, p², 2pq and q² together, with the carriers as roughly 1 in N.
  4. 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

p + q = 1 \qquad p^2 + 2pq + q^2 = 1
SymbolMeaning
pFrequency of the dominant allele, A
qFrequency of the recessive allele, a
p²Frequency of homozygous dominant individuals, AA
2pqFrequency 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:

q = \sqrt{0.0004} = 0.02 \qquad p = 0.98 \qquad 2pq = 2 \times 0.98 \times 0.02 = 0.0392

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.

q = \sqrt{0.16} = 0.4 \qquad p = 0.6 \qquad p^2 = 0.36,\ \ 2pq = 0.48

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.

y = 2\mathrm{x}\left(1- x\right)
0.10.20.30.40.50.60.70.80.91-6-4-2246Max 0.5q = 0.4
2pq = 2q(1 − q)Drag to pan, scroll to zoom. x from 0 to 1, y from -6 to 6.

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.

p = \frac{2 \times 260 + 205}{2 \times 500} = \frac{725}{1000} = 0.725 \qquad q = 0.275

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:

practice
Pick an answer, then check it.
In a population, 9% show a recessive phenotype. What is the frequency of the dominant allele, p?

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.

GenotypeObservedExpected(O − E)²/E
AA3803601.111
Aa4404803.333
aa1801602.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?
p² + 2pq + q² = 1, together with p + q = 1. p and q are allele frequencies, and p², 2pq and q² are the frequencies of the AA, Aa and aa genotypes.
How do you find q in Hardy-Weinberg?
Take the square root of the share with the recessive phenotype, q². If 25% show it, q = √0.25 = 0.5.
How do you calculate carrier frequency?
Find q from the recessive phenotype, then p = 1 − q, then carriers = 2pq. For a condition affecting 1 in 2,500, 2pq = 0.0392, about 1 in 25.5.
How do you find allele frequencies from genotype counts?
p = (2 × AA + Aa) ÷ (2 × total). This counts the A alleles directly and does not assume equilibrium.
How do you test for Hardy-Weinberg equilibrium?
Work out the expected counts p²N, 2pqN and q²N, then χ² = Σ(O − E)²/E. With 1 degree of freedom, a value above 3.841 means the population is not in equilibrium at the 5% level.
What are the five Hardy-Weinberg conditions?
Random mating, no selection, no mutation, no migration and a very large population.

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
Read next
Biology · Genetics and inheritancePunnett square calculator: monohybrid and dihybridMake a Punnett square for any monohybrid or dihybrid cross, with genotype and phenotype ratios, the chance of each outcome and worked examples.