Hardy-Weinberg: what are p and q?
Type the counts of AA, Aa and aa in a sample, or one frequency you know, such as the share of a population with the recessive trait. The Hardy Weinberg calculator gives p, q, p², 2pq and q², and tests whether the counts fit equilibrium.
- q (allele a)
- 0.0459
The allele frequencies are p = 0.9541 and q = 0.0459.
- p (allele A)
- 0.9541
- p² (AA)
- 0.9103
- 2pq (Aa)
- 0.0876
- q² (aa)
- 0.0021
- Expected AA
- 1,467.4
- Expected Aa
- 141.2
- Expected aa
- 3.4
- Chi-square (1 degree of freedom)
- 0.831
- p-value
- 0.362
- At the 5% level
- Fits Hardy-Weinberg proportions (p ≥ 0.05)
q (allele a): 0.0459. The allele frequencies are p = 0.9541 and q = 0.0459.
Genotype frequencies in equilibrium
How to calculate
Computes the allele frequencies p and q and the genotype frequencies p², 2pq and q² from genotype counts or one known frequency, with the expected counts and a chi-square test of Hardy-Weinberg equilibrium.
Example with the default inputs (I know Genotype counts, AA (homozygous dominant) 1,469, Aa (heterozygous) 138, aa (homozygous recessive) 5): The allele frequencies are p = 0.9541 and q = 0.0459.
Method: p + q = 1; p² + 2pq + q² = 1. From counts: p = (2 × AA + Aa) ÷ 2N; expected = N × (p², 2pq, q²); χ² = Σ (O − E)² ÷ E with 1 degree of freedom.
- One gene with two alleles, A dominant over a. Hardy-Weinberg proportions hold with random mating and no selection, mutation, migration or drift.
- From q² (or p²), q (or p) is its square root.
- The chi-square test has 1 degree of freedom (3 genotypes − 2 alleles); it is shaky when an expected count is below about 5.
Worked examples
Each example is checked against the calculator on every build.
- I know One frequency, The frequency I know q² (aa, shows the recessive trait), Its value 0.09 gives q (allele a) 0.3, p (allele A) 0.7, p² (AA) 0.49, 2pq (Aa) 0.42, q² (aa) 0.09.Source: OpenStax, Biology 2e, section 19.1 Population Evolution (Hardy-Weinberg: p + q = 1 and p² + 2pq + q² = 1; with p = 0.7 and q = 0.3 the genotype frequencies are 0.49, 0.42 and 0.09), CC BY 4.0, https://openstax.org/books/biology-2e/pages/19-1-population-evolution (retrieved 2026-10-03)
- I know Genotype counts, AA (homozygous dominant) 1,469, Aa (heterozygous) 138, aa (homozygous recessive) 5 gives p (allele A) 0.954094, Expected AA 1,467.397022, Expected Aa 141.205955, Expected aa 3.397022, Chi-square (1 degree of freedom) 0.830948, p-value 0.361998, At the 5% level Fits Hardy-Weinberg proportions (p ≥ 0.05).Source: Wikipedia, Hardy–Weinberg principle, section Significance tests (Ford’s scarlet tiger moths: 1,469 AA, 138 Aa, 5 aa; p = 0.954; expected 1,467.4, 141.2 and 3.4; χ² = 0.83 with 1 degree of freedom, below the 5% critical value 3.84), https://en.wikipedia.org/wiki/Hardy%E2%80%93Weinberg_principle (retrieved 2026-10-03); OpenStax, Biology 2e, section 19.1 Population Evolution (Hardy-Weinberg: p + q = 1 and p² + 2pq + q² = 1; with p = 0.7 and q = 0.3 the genotype frequencies are 0.49, 0.42 and 0.09), CC BY 4.0, https://openstax.org/books/biology-2e/pages/19-1-population-evolution (retrieved 2026-10-03)
- I know Genotype counts, AA (homozygous dominant) 30, Aa (heterozygous) 20, aa (homozygous recessive) 50 gives p (allele A) 0.4, q (allele a) 0.6, Expected AA 16, Expected Aa 48, Expected aa 36, Chi-square (1 degree of freedom) 34.027778.Source: OpenStax, Biology 2e, section 19.1 Population Evolution (Hardy-Weinberg: p + q = 1 and p² + 2pq + q² = 1; with p = 0.7 and q = 0.3 the genotype frequencies are 0.49, 0.42 and 0.09), CC BY 4.0, https://openstax.org/books/biology-2e/pages/19-1-population-evolution (retrieved 2026-10-03)
- I know One frequency, The frequency I know p (allele A), Its value 0.25 gives q (allele a) 0.75, p² (AA) 0.0625, 2pq (Aa) 0.375, q² (aa) 0.5625.Source: OpenStax, Biology 2e, section 19.1 Population Evolution (Hardy-Weinberg: p + q = 1 and p² + 2pq + q² = 1; with p = 0.7 and q = 0.3 the genotype frequencies are 0.49, 0.42 and 0.09), CC BY 4.0, https://openstax.org/books/biology-2e/pages/19-1-population-evolution (retrieved 2026-10-03)
How it works
From genotype counts AA, Aa and aa (whole numbers, at least one above 0), with N = AA + Aa + aa:
- p = (2 × AA + Aa) ÷ (2 × N); q = 1 − p.
- p², 2pq and q² from these p and q.
- Expected counts: AA = N × p², Aa = N × 2pq, aa = N × q².
- χ² = (AA − N p²)² ÷ (N p²) + (Aa − 2N pq)² ÷ (2N pq) + (aa − N q²)² ÷ (N q²), with 1 degree of freedom.
- p-value = the chance that a chi-square variable with 1 degree of freedom is at least χ² (its upper tail, which equals erfc(√(χ² ÷ 2))).
- At the 5% level: “Fits Hardy-Weinberg proportions (p ≥ 0.05)” when the p-value is 0.05 or more, otherwise “Does not fit Hardy-Weinberg proportions (p < 0.05)”.
- When p is 0 or 1 (only one allele in the sample), the chi-square and p-value are left out and the verdict reads “No test: the sample has only one allele”.
From one frequency f from 0 to 1: known p gives p = f; known q gives p = 1 − f; known p² gives p = √f; known q² gives p = 1 − √f. Then q = 1 − p, and p², 2pq and q² follow. No expected counts or test are shown.
Exact arithmetic. Counts and typed frequencies are exact decimals, so p, q and the expected counts are exact fractions, rounded once for display. A square root is exact when the typed value is a perfect square of a decimal (0.09 gives 0.3), and a float otherwise.
Output format. Frequencies show 4 decimals, expected counts 1 decimal, χ² 3 decimals, and the p-value 4 significant figures.
Worked examples by hand
OpenStax’s pea plants: q² = 0.09. q = √0.09 = 0.3, p = 0.7, p² = 0.49, 2pq = 2 × 0.7 × 0.3 = 0.42, q² = 0.09.
Ford’s scarlet tiger moths: 1,469 AA, 138 Aa, 5 aa. N = 1,612; p = (2,938 + 138) ÷ 3,224 = 0.9541. Expected: 1,612 × 0.9541² = 1,467.4, 1,612 × 2 × 0.9541 × 0.0459 = 141.2, 1,612 × 0.0459² = 3.4. χ² = 0.002 + 0.073 + 0.756 = 0.831, below 3.84; p-value = 0.362, so the counts fit.
30 AA, 20 Aa, 50 aa. N = 100; p = (60 + 20) ÷ 200 = 0.4, q = 0.6. Expected: 16, 48 and 36. χ² = 14² ÷ 16 + 28² ÷ 48 + 14² ÷ 36 = 12.25 + 16.333 + 5.444 = 34.028, far above 3.84: the counts do not fit.
Known p = 0.25. q = 0.75, p² = 0.0625, 2pq = 0.375, q² = 0.5625.
Other questions people ask
What is the Hardy-Weinberg equation?
For one gene with two alleles, A with frequency p and a with frequency q, p + q = 1. In a population in equilibrium the genotype frequencies are p² for AA, 2pq for Aa and q² for aa, and p² + 2pq + q² = 1.
How do I find p and q from genotype counts?
Count the alleles. Each AA has two A alleles and each Aa has one, so p = (2 × AA + Aa) ÷ (2 × total). Then q = 1 − p. With 30 AA, 20 Aa and 50 aa, p = 80 ÷ 200 = 0.4 and q = 0.6.
How do I use the share with the recessive trait?
Only aa shows the recessive trait, so that share is q². Take its square root for q. If 9% show the trait, q = √0.09 = 0.3, p = 0.7, and 2pq = 0.42 of the population are carriers.
How does the chi-square test work here?
The calculator works out the counts expected from p and q, then χ² = Σ (observed − expected)² ÷ expected. With 3 genotypes and 2 alleles there is 1 degree of freedom, so χ² above 3.84 means p < 0.05: the counts do not fit equilibrium at the 5% level.
What does it mean if my population is not in equilibrium?
One of the conditions does not hold: mating is not random, or selection, mutation, migration or genetic drift is changing the allele frequencies. OpenStax describes these as the forces of evolution.
Why is there no test when I type one frequency?
A test needs observed counts to compare with the expected ones. From one frequency the calculator can only assume equilibrium and fill in the rest.