What the calculator does
The Hardy–Weinberg principle describes how allele and genotype frequencies relate to each other in a population that is not evolving. For one gene with two alleles, a dominant allele A and a recessive allele a, this calculator gives you:
- the allele frequencies p (for A) and q (for a);
- the expected genotype frequencies p² (AA), 2pq (Aa) and q² (aa);
- expected numbers of individuals, if you give a population size;
- a χ² goodness-of-fit test, if you enter observed genotype counts.
How to use it
Choose the option that matches the information you have.
- Genotype counts. Use this when you know how many individuals have each genotype, for example from genetic testing. The calculator counts alleles directly and then tests whether the counts fit Hardy–Weinberg proportions.
- Recessive phenotype. Use this when you know how common a recessive trait is, such as 1 in 2,500. Enter it as a decimal, a fraction (1/2500) or a percentage (0.04%).
- Allele frequency. Use this when you already know p or q.
Then press Calculate. Results appear alongside the form, with the full working below.
The formulas
The two allele frequencies account for every allele in the population, so they add up to 1:
When mating is random, the two alleles an individual inherits are like two independent draws from the population’s allele pool. That gives the genotype frequencies:
The heterozygote term is 2pq rather than pq because an Aa individual can inherit A from either parent: A from the mother and a from the father, or the other way round.
Variables
| Symbol | Meaning |
|---|---|
| p | Frequency of the dominant allele, A |
| q | Frequency of the recessive allele, a |
| p² | Expected frequency of homozygous dominant individuals (AA) |
| 2pq | Expected frequency of heterozygous individuals (Aa), the carriers of a recessive trait |
| q² | Expected frequency of homozygous recessive individuals (aa) |
| N | Number of individuals in the sample or population |
Allele frequencies from genotype counts
When genotypes can be counted, p comes from counting alleles. Each AA individual carries two A alleles, each Aa individual carries one, and there are 2N alleles in total:
This does not assume equilibrium, which is what makes it possible to test for equilibrium afterwards.
Worked example
In a classic study, E. B. Ford recorded genotypes in a colony of scarlet tiger moths (Callimorpha dominula). The colour pattern gene has three distinguishable genotypes. The sample contained 1,469 AA, 138 Aa and 5 aa moths, a total of N = 1,612.
- Count the alleles. p = (2 × 1469 + 138) / (2 × 1612) = 3076 / 3224 = 0.9541.
- Find q. q = 1 − p = 0.04591.
- Expected genotype frequencies. p² = 0.9103, 2pq = 0.0876 and q² = 0.002107.
- Expected counts. Multiplying by 1,612 gives 1467 AA, 141.2 Aa and 3.397 aa.
- χ² test. Comparing these with the observed 1,469, 138 and 5 gives χ² = 0.8309 with 1 degree of freedom, p-value = 0.362.
The p-value is well above 0.05, so the observed genotypes are consistent with Hardy–Weinberg proportions. The expected aa count of 3.397 is below 5, so the calculator also warns that the χ² approximation is unreliable here. An exact test would be the more rigorous choice.
Testing a population for equilibrium
With observed genotype counts, the calculator compares each observed count (O) with its expected count (E):
The statistic is compared with a χ² distribution with 1 degree of freedom. A p-value below 0.05 means the genotype counts differ more than chance alone would usually produce. A p-value of 0.05 or above means there is no significant evidence of a departure. It does not prove the population is in equilibrium.
When any expected count is below 5, the χ² approximation becomes unreliable, and the calculator tells you so. Exact tests, as described by Wigginton and colleagues (2005), are preferred for small samples or rare alleles.
Common mistakes
- Taking p as the square root of the dominant phenotype frequency. The dominant phenotype includes both AA and Aa individuals, so its frequency is p² + 2pq, not p². Always start from the recessive phenotype, q².
- Confusing p with p². p is an allele frequency; p² is a genotype frequency. If p = 0.6, the frequency of AA individuals is 0.36, not 0.6.
- Forgetting the 2 in 2pq. Heterozygotes can arise in two ways, so their frequency is twice pq.
- Treating “not significant” as proof. A non-significant χ² result only means no departure was detected.
- Using phenotype data to test for equilibrium. If you calculated q from the recessive phenotype, you already assumed equilibrium. You cannot then use the same data to test it.
Practical applications
- Genetic counselling and public health. Estimating carrier frequencies for recessive conditions from how often the condition occurs.
- Quality control in genetic studies. Genome-wide association studies routinely test each genetic marker for Hardy–Weinberg equilibrium. Strong departures can reveal genotyping errors.
- Evolutionary biology. Departures from expected proportions can point to selection, inbreeding, population structure or migration.
- Conservation genetics. Monitoring genetic diversity and inbreeding in small or isolated populations.
Assumptions and limitations
Hardy–Weinberg expectations hold only in an idealised population: mating is random, there is no selection, mutation or migration, and the population is large enough for chance changes in allele frequency (genetic drift) to be negligible. Real populations never meet all of these exactly, which is why the principle is useful as a baseline to measure against.
This calculator handles one gene with two alleles, with A completely dominant over a. It does not cover genes with three or more alleles, such as the ABO blood group, or sex-linked genes, which have different expected frequencies in males and females.