Biology · Population genetics
Hardy-Weinberg calculator.
Get expected genotype frequencies from p or q, estimate carriers from a recessive frequency, or run the chi-square test on observed counts.
Inputs
Hardy-Weinberg results
Enter a frequency or counts.
The Hardy-Weinberg equation
For a gene with two alleles at frequencies p and q, where p + q = 1, a population with random mating and none of the disturbing forces has genotype frequencies p² (AA), 2pq (Aa) and q² (aa). Wikipedia lists seven assumptions: diploid organisms, sexual reproduction, non-overlapping generations, random mating, a very large population, equal allele frequencies in the sexes, and no migration, gene flow, admixture, mutation or selection.
Worked example (chi-square). Wikipedia's example uses E. B. Ford's 1971 scarlet tiger moth data: 1469 AA, 138 Aa and 5 aa (1612 moths). The tool gets p = 0.9541 and expects 1,467.4, 141.2 and 3.4, for a chi-square of 0.83. With 1 degree of freedom (3 genotypes minus 2 alleles) the 5% critical value is 3.84, so the population is not rejected as being in Hardy-Weinberg proportions. The smallest expected count here is only 3.4, below the rule-of-thumb 5, so the result is approximate.
Worked example (carriers). Wikipedia's carrier example assumes about 1 in 2,500 babies are born with cystic fibrosis in Northern European populations. Then q² = 0.0004, q = 0.02, p = 0.98 and 2pq = 0.0392, roughly 1 carrier in 25.5. Wikipedia's shortcut of about twice the square root of the birth frequency gives 1 in 25.
Frequently asked questions
What do p and q mean?
p is the frequency of the dominant allele (A) and q the frequency of the recessive allele (a) in the population. With two alleles, p + q = 1.
How do I find the carrier frequency from the recessive frequency?
Take the square root of the recessive phenotype frequency to get q, then p = 1 - q and carriers = 2pq. For q squared = 1/2500 that gives q = 0.02 and carriers of about 3.9%.
How many degrees of freedom does the test have?
One, for a gene with two alleles: Wikipedia gives degrees of freedom as the number of genotypes minus the number of alleles, which is 3 - 2.
What does a significant result mean?
The observed genotype counts are unlikely under Hardy-Weinberg proportions, so at least one assumption, such as random mating, no selection or a large population, probably fails. It does not say which one.
Does it work for X-linked genes or more than two alleles?
No. This calculator covers one autosomal gene with two alleles. The allele frequency calculator handles up to four alleles from counts.
Sources
Checked
- Wikipedia: Hardy–Weinberg principle
- Wikipedia: Pearson’s chi-squared test
- OpenStax Biology 2e: 12.3 Laws of Inheritance
Runs entirely in your browser. Nothing you type is sent or stored.
Teaching model, not advice
A population-genetics teaching model. Carrier estimates are not a substitute for genetic counselling or testing.