Toolvito

Works on this device

Hardy Weinberg Calculator

Work with the Hardy-Weinberg equation p² + 2pq + q² = 1. Test real genotype counts against the numbers the equation expects, or find p, q and the carrier share from how common a recessive trait is.

Enter your values

Type how many individuals have each genotype. The tool finds p and q, the expected numbers and tests the fit.

Your values

AA: two copies of the dominant allele A (homozygous dominant).

Aa: one copy of each allele (heterozygous).

aa: two copies of the recessive allele a (homozygous recessive).

The chance of a false alarm you accept. 0.05 is the most common choice.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose the button below them.

How to use this calculator

  1. Choose what you want to do. Test genotype counts checks counts of AA, Aa and aa. Solve the equation from the recessive trait starts from q², the share of individuals that show a recessive trait. Genotype frequencies from p or q starts from one allele frequency.
  2. Type the numbers you know. Counts are whole numbers of individuals. Shares are from 0 to 1, and percentages from 0 to 100.
  3. For more than two alleles of one gene, choose Test genotype counts (two or more alleles) and type one row for each genotype, such as A1/A2.
  4. Choose Test or Calculate. The result shows the frequencies, the expected numbers, the test and the working.

The Hardy-Weinberg equation

For a gene with two alleles, A and a, let p be the frequency of A and q the frequency of a. Then p + q = 1.

In a population in Hardy-Weinberg equilibrium the genotype frequencies are p² for AA, 2pq for Aa and q² for aa, and p² + 2pq + q² = 1.

  • From counts: p = (2 × number of AA + number of Aa) ÷ (2 × N), where N is the number of individuals. q = 1 − p.
  • From a recessive trait: only aa individuals show it, so its share is q². Then q = √q² and p = 1 − q.
  • Expected numbers: p² × N, 2pq × N and q² × N.
  • Chi-square test: X² = Σ (observed − expected)² ÷ expected. With two alleles the test has 1 degree of freedom: 3 genotypes, minus 1 for the total, minus 1 for the allele frequency taken from the same counts. With k alleles it has k(k − 1) ÷ 2 degrees of freedom.
  • p-value: the chance of an X² at least this large if the population were in equilibrium. A p-value below the significance level (often 0.05) means the counts depart from Hardy-Weinberg proportions.
  • Exact test (two alleles): adds up the chances of every possible number of heterozygotes that is not more likely than the number seen, for the same allele counts (Wigginton, Cutler and Abecasis, 2005). It is the better test when numbers are small.

Worked examples

Counts. In 1,000 individuals, 298 are AA, 489 are Aa and 213 are aa. There are 2,000 allele copies, and A has 2 × 298 + 489 = 1,085 of them, so p = 0.5425 and q = 0.4575. The expected numbers are 294.31 AA, 496.39 Aa and 209.31 aa. X² = 0.2215 with 1 degree of freedom, so the p-value is 0.638. These counts show no clear departure from equilibrium at the 0.05 level.

Recessive trait. 16% of a population show a recessive trait, so q² = 0.16. Then q = 0.4, p = 0.6, p² = 0.36 and 2pq = 0.48: about 1 in 2.08 individuals is a heterozygous carrier.

Limits you should know

  • The equation describes an ideal population: very large, mating at random, with no selection, mutation or migration for this gene. Real populations only come close to it.
  • Finding q from a recessive trait assumes equilibrium. To check equilibrium you need genotype counts, not only the share with the trait.
  • The chi-square p-value is rough when an expected number is below 5. For two alleles, the exact test is shown beside it. For more than two alleles no exact test is given.
  • A large p-value does not prove equilibrium. It only says the counts do not show a clear departure.
  • For genotype and allele frequencies without a test, use the Genotype Frequency Calculator or the Allele Frequency Calculator. For the offspring of one cross, use the Punnett Square Calculator.

Related tools