# Hardy-Weinberg: what are p and q?

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.

- Page: https://www.acalculator.org/biology/hardy-weinberg-calculator
- JSON spec: https://www.acalculator.org/biology/hardy-weinberg-calculator.json
- Version: 22d926430d25

## Default answer

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.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| mode | I know | Genotype counts from a sample, or one frequency (such as the share with the recessive trait). |
| AA | AA (homozygous dominant) | How many individuals in the sample are AA. |
| Aa | Aa (heterozygous) | How many individuals in the sample are Aa. |
| aa | aa (homozygous recessive) | How many individuals in the sample are aa. |
| k | The frequency I know | Which frequency you have: q² is the share of individuals that show the recessive trait. |
| f | Its value | The known frequency as a decimal from 0 to 1 (9% is 0.09). |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| p | p (allele A) | The frequency of the dominant allele A. |
| q | q (allele a) | The frequency of the recessive allele a: 1 − p. |
| p2 | p² (AA) | The expected frequency of AA. |
| pq2 | 2pq (Aa) | The expected frequency of Aa, the carriers. |
| q2 | q² (aa) | The expected frequency of aa. |
| expDom | Expected AA | N × p², the AA count expected in equilibrium. |
| expHet | Expected Aa | N × 2pq, the Aa count expected in equilibrium. |
| expRec | Expected aa | N × q², the aa count expected in equilibrium. |
| chi | Chi-square (1 degree of freedom) | Σ (observed − expected)² ÷ expected over the three genotypes. |
| pValue | p-value | The chance of a chi-square this large or larger if the population is in equilibrium. |
| verdict | At the 5% level | Whether the counts fit Hardy-Weinberg proportions (p-value of 0.05 or more). |

## 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.

## Assumptions

- 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

1. mode = frequency, k = q2, f = 0.09 gives q = 0.3, p = 0.7, p2 = 0.49, pq2 = 0.42, q2 = 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).
2. mode = counts, AA = 1,469, Aa = 138, aa = 5 gives p = 0.954094, expDom = 1,467.397022, expHet = 141.205955, expRec = 3.397022, chi = 0.830948, pValue = 0.361998, verdict = 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).
3. mode = counts, AA = 30, Aa = 20, aa = 50 gives p = 0.4, q = 0.6, expDom = 16, expHet = 48, expRec = 36, chi = 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).
4. mode = frequency, k = p, f = 0.25 gives q = 0.75, p2 = 0.0625, pq2 = 0.375, q2 = 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).

## FAQ

### 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.

## Sources

- OpenStax, Biology 2e, section 19.1 Population Evolution (p + q = 1; p² + 2pq + q² = 1; the pea example with p = 0.7, q = 0.3 gives 0.49, 0.42 and 0.09; the conditions of Hardy-Weinberg equilibrium), CC BY 4.0, retrieved 2026-10-03. https://openstax.org/books/biology-2e/pages/19-1-population-evolution
- Wikipedia, Hardy–Weinberg principle, section Significance tests (Pearson’s chi-squared test with 1 degree of freedom; Ford’s scarlet tiger moths: 1,469, 138 and 5, χ² = 0.83 below the 5% critical value 3.84), retrieved 2026-10-03. https://en.wikipedia.org/wiki/Hardy%E2%80%93Weinberg_principle
