Saved

Press the star next to a tool's name to save it.

All my tools

Hardy Weinberg Equilibrium Calculator

Use this Hardy Weinberg equilibrium calculator to find expected genotype shares, allele frequencies from counts, a chi-squared test and the carrier share of a recessive condition.

Restored your last values ·

Enter p or q to get the expected genotype shares p², 2pq and q². Or enter observed genotype counts to get p and q, the expected counts and a chi-squared test with 1 degree of freedom. Or enter the share of people with a recessive condition to estimate the carriers.

Everything is worked out in your browser. Nothing you type is sent anywhere.

–

–

Choose what to work out, fill in the boxes, then press Calculate.

A Hardy Weinberg equilibrium calculator shows the genotype shares you expect for a gene with two alleles when a population is in equilibrium, and tests whether observed genotype counts fit that expectation. Enter an allele frequency, or counts of AA, Aa and aa people, and it works out p, q, the expected genotypes, a chi-squared test and the inbreeding coefficient.

How to use the Hardy Weinberg equilibrium calculator

  1. Choose a mode: genotype shares from p or q, a test of observed counts, or carriers from the incidence of a recessive condition.
  2. Enter p or q as a decimal, a percentage or a fraction, or enter the three observed counts.
  3. Press Calculate.

What the principle says

The Wikipedia article on the Hardy–Weinberg principle says that allele and genotype frequencies in a population stay constant from generation to generation in the absence of other evolutionary influences.[1] For alleles A and a with frequencies p and q, the page gives p + q = 1 and the genotype frequencies f(AA) = p², f(Aa) = 2pq and f(aa) = q², which add up to 1 because they come from the expansion of (p + q) squared.[1] This is the whole basis of the first mode. Enter p = 0.3 and the calculator gives q = 0.7 and genotype shares of 9 percent AA, 42 percent Aa and 49 percent aa.

Finding p and q from counts

The page gives the pooling rule: the frequency of A is the frequency of AA plus half the frequency of Aa, and the frequency of a is the frequency of aa plus half the frequency of Aa.[1] In counts, p = (2 × AA + Aa) ÷ (2 × the total number of people), and q = 1 − p.[1] Each AA person carries two copies of A and each Aa person carries one, which is why the counts are doubled.

The worked example from the page

The page tests data from Ford (1971) on the scarlet tiger moth: 1,469 AA, 138 Aa and 5 aa, a total of 1,612 moths. The frequency p is 3,076 ÷ 3,224 = 0.954 and q is 0.046.[1] The expected counts are about 1,467.4 AA, 141.2 Aa and 3.4 aa.[1] Enter 1469, 138 and 5 and the calculator gives p = 0.95409, q = 0.045906 and expected counts of 1,467.4, 141.21 and 3.397.

The chi-squared test

The page says that testing deviation from the principle is generally done with Pearson's chi-squared test, comparing observed and expected genotype counts.[1] The degrees of freedom are the number of genotypes minus the number of alleles, so for two alleles it is 3 − 2 = 1.[1] For the moth data, the page gets chi-squared = 0.001 + 0.073 + 0.756 = 0.83, below the 5 percent critical value of 3.84 for one degree of freedom, so the null hypothesis of equilibrium is not rejected.[1] The calculator shows the more exact 0.8309 and a p-value near 0.36. It also warns when an expected count is below 5, as it is here; the page notes that for many alleles sparse classes can break the chi-squared approximation, and that exact tests can then be used instead.[1]

The inbreeding coefficient

The page also gives the inbreeding coefficient for Ford's data as F = 1 − 138 ÷ 141.2 = 0.023.[1] It compares the observed number of heterozygotes with the number expected. Values near 0 mean the heterozygote count is close to equilibrium, and positive values mean there are fewer heterozygotes than expected. The calculator shows this value in the counts mode.

Carriers of a recessive condition

The third mode starts from the share of people who have a recessive condition, which equals q². The square root gives q, p is 1 − q, and the share of carriers is 2pq, the heterozygote frequency from the page.[1] If a condition affects 1 person in 2,500, then q = 0.02, p = 0.98 and carriers are 2 × 0.98 × 0.02 = 3.92 percent, about 1 in 25.5. This example uses an assumed incidence of our own and is a textbook-style illustration, not a figure from the page. It is only as good as the assumptions of equilibrium and random mating.

When equilibrium does not hold

The page lists the assumptions: diploid organisms, sexual reproduction only, non-overlapping generations, random mating, a very large population, equal allele frequencies in the sexes, and no migration, gene flow, admixture, mutation or selection.[1] If mating is not random the genotype proportions change, and if selection, mutation, migration or a small population is involved, the allele frequencies change over time.[1] The page also says that deviations can point to genotyping error.[1] For genes on the X chromosome the page describes different proportions in the two sexes, and for more than two alleles it gives f(AiAi) = pi² and f(AiAj) = 2pipj; this calculator covers two alleles on an autosome only.[1]

A short example with a table of shares

Suppose q = 0.1. Then p = 0.9, and the expected shares are p² = 0.81 for AA, 2pq = 0.18 for Aa and q² = 0.01 for aa, which add up to 1. In a town of 10,000 people you would expect about 8,100 AA, 1,800 Aa and 100 aa. Notice that the carriers outnumber the affected people eighteen to one. This is the main reason the principle matters in genetics: most copies of a rare recessive allele are hidden in heterozygotes, where they are not expressed. These numbers are our own worked example from the formulas above.

Reading your result

A large p-value from the chi-squared test means the counts are consistent with equilibrium. A small one means they are not, and you should then ask which assumption failed: non-random mating, selection, a small population or a genotyping error. The inbreeding coefficient helps to tell the cases apart, since a clearly positive value points to a shortage of heterozygotes.

Common mistakes

  • Using the incidence as q. The share of affected people is q², not q.
  • Entering percentages of people as counts. The test needs counts, not shares.
  • Treating a non-significant result as proof of equilibrium. Small samples have little power.

What next

Use this often? Add Hardy Weinbe to your Home screen.

Frequently asked questions

What is a Hardy Weinberg equilibrium calculator?

A tool that works out expected genotype shares for a two-allele gene, finds allele frequencies from genotype counts and tests whether the counts fit equilibrium.

What is the Hardy-Weinberg equation?

p + q = 1 for the allele frequencies and p² + 2pq + q² = 1 for the genotype frequencies of AA, Aa and aa.

How do I find p and q from genotype counts?

p = (2 × AA + Aa) ÷ (2 × total people) and q = 1 − p.

How many degrees of freedom does the chi-squared test have?

The number of genotypes minus the number of alleles. For two alleles that is 3 − 2 = 1.

How do I find the carrier share of a recessive condition?

Take the square root of the share of affected people to get q, then carriers are 2pq, assuming equilibrium and random mating.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Education Tools