Hardy-Weinberg calculator

This Hardy-Weinberg calculator works two ways. Enter the observed genotype counts to get allele frequencies, expected counts and a chi-square test of equilibrium. Or enter one known frequency, such as the share of a population with a recessive condition, to get p, q and the carrier frequency.

Your numbers are calculated in your browser. Nothing you enter is sent or stored.

Hardy-Weinberg calculatorOr describe it in Studio →

Counts of individuals with each genotype in your sample.

Consistent with Hardy-Weinberg equilibrium (p = 0.6379).

GenotypeObservedExpectedFrequency
AA298294.310.2943
Aa489496.390.4964
aa213209.310.2093
p (allele A)
0.5425
q (allele a)
0.4575
Chi-square (1 df)
0.221
p value
0.6379

To report

p = 0.542, q = 0.458; χ²(1, N = 1000) = 0.22, p = 0.6379

Check your result: the expected counts must add up to the sample size, 294.31 + 496.39 + 209.31 = 1,000 for the worked example (to rounding), and p + q = 1. Observed and expected should be close when the chi-square is small: here the largest gap is 7.4 heterozygotes.
chi-square in the worked example
0.221
chi-square in the worked example
its p value, 1 degree of freedom
0.638
its p value, 1 degree of freedom
carriers when 4% are affected
32%
carriers when 4% are affected
degree of freedom, not 2
1
degree of freedom, not 2
  • Allele frequencies p and q
  • Expected genotype counts
  • Chi-square test, 1 df
  • Carrier frequency from q²
  • Runs in your browser, free

01

Hardy-Weinberg equation

p + q = 1

p² + 2pq + q² = 1

p and q are the frequencies of the two alleles, A and a. In a population at equilibrium, p² is the frequency of AA, 2pq of Aa and q² of aa. From counts, p = (2 × AA + Aa) ÷ (2 × N).

07.815145%test statistic
A right-tail p value. Statistics such as chi-square, F and H can only be zero or positive, and larger values mean a worse fit to the null hypothesis. The p value is the area to the right of your statistic. The curve shown has 3 degrees of freedom; 5% of its area lies beyond 7.815.

02

Worked example: testing equilibrium

A sample of 1,000 people has 298 AA, 489 Aa and 213 aa.

p = (2 × 298 + 489) ÷ 2000 = 0.5425, q = 0.4575

GenotypeObservedExpected
AA298294.31
Aa489496.39
aa213209.31

Chi-square = 0.221 with 1 degree of freedom, p = 0.638. The counts are consistent with Hardy-Weinberg equilibrium.

03

Worked example: carrier frequency

A recessive condition affects 4% of a population, so q² = 0.04.

q = √0.04 = 0.2, p = 0.8

carriers: 2pq = 2 × 0.8 × 0.2 = 0.32

About 32% of the population carries one copy of the allele.

04

Assumptions

The equation holds for a large, randomly mating population with no selection, mutation or migration at the locus. A significant chi-square says the counts do not fit those proportions; it does not say which assumption failed. In genotyping studies a departure is often a sign of genotyping error. The test has 1 degree of freedom: three genotype classes, minus one, minus one allele frequency estimated from the data.

05

Common mistakes with Hardy-Weinberg

  • Using 2 degrees of freedom. The worked example’s chi-square of 0.221 gives p = 0.638 with the correct 1 degree of freedom; with 2 it would be 0.895. One degree is lost for estimating p from the data.
  • Taking the affected fraction as q. If 4% are affected, q² = 0.04 and q = 0.2, giving 32% carriers. Treating 0.04 as q gives 7.7% carriers, a quarter of the real figure.
  • Counting alleles from one genotype. p is (2 × AA + Aa) ÷ 2N = 0.5425 in the worked example; the AA fraction alone, 0.298, is not an allele frequency.
  • Testing a rare allele with chi-square. With 980 AA, 20 Aa and 0 aa the expected aa count is 0.1, far below the usual minimum of 5, so the chi-square p value of 0.749 is not reliable; an exact test is better.

Trust

How this page is checked

  • The calculation runs on code with automated tests against worked reference values. Every number in the examples on this page was produced by that same code, not typed by hand.
  • The formulas and conventions used are stated on the page, so you can reproduce the result yourself or compare it with your own software.
  • Last reviewed by the Sciloom team, Zebra Nine Studio Inc. It is a tool for research and teaching, not a substitute for a statistician, a validated lab method or medical advice.

Cite this page

Sciloom. (2026). Hardy-Weinberg calculator. Zebra Nine Studio Inc. https://sciloom.si/hardy-weinberg-calculator

Read the full methodology · Who makes Sciloom

Frequently asked questions

How do I calculate allele frequencies from genotype counts?

Count alleles: each AA carries two A alleles and each Aa carries one. p = (2 × AA + Aa) ÷ (2 × total), and q = 1 − p.

How do I find the carrier frequency?

Take the square root of the frequency of the recessive phenotype to get q, then compute 2pq. If 1 in 2,500 is affected, q = 0.02, p = 0.98 and 2pq = 0.0392, about 1 in 26.

Why 1 degree of freedom and not 2?

There are three genotype classes, which would give 2, but one more is lost because the allele frequency is estimated from the same data.

What if an expected count is below 5?

The chi-square approximation becomes unreliable, which is common when one allele is rare. Use an exact test for Hardy-Weinberg proportions instead. The calculator warns you when this happens.

Testing a different table of counts? Use the chi-square calculator.
Free to start, no sign-up.
Back to the tool ↑

More research tools