Pedigree
Tools Learn
Tool

Hardy-Weinberg equilibrium calculator

Enter observed genotype counts to calculate allele frequencies, test for HWE with chi-square, and see expected vs observed. Or enter allele frequency p directly to explore the equations.

Input mode

Enter the number of individuals observed with each genotype.

Enter a whole number ≥ 0
Enter a whole number ≥ 0
Enter a whole number ≥ 0

Need to analyse a full family tree?

Use the pedigree tool to map multiple generations and check inheritance patterns.

Open the pedigree tool

How the Hardy-Weinberg equilibrium calculator works

The Hardy-Weinberg equilibrium calculator takes observed allele or genotype counts from a population and computes the genotype frequencies you would expect if the population were in equilibrium. It then compares observed versus expected counts using a chi-square test and reports whether the deviation is statistically significant.

The Hardy-Weinberg principle

Hardy-Weinberg equilibrium describes what happens to allele and genotype frequencies in a population when no evolutionary forces are at work. The principle depends on five conditions: the population is effectively infinite (so genetic drift is negligible), mating is random with respect to the gene in question, no new mutations are occurring, there is no migration in or out, and no genotype has a selective advantage. When all five hold, allele frequencies remain constant from one generation to the next, and genotype frequencies settle into a predictable ratio determined by those allele frequencies.

For a gene with two alleles, A and a, let p represent the frequency of allele A and q represent the frequency of allele a. Because these are the only two alleles at this locus, p + q = 1. Under Hardy-Weinberg equilibrium, the expected genotype frequencies are p² for AA, 2pq for Aa, and q² for aa. These three terms always sum to 1, since (p + q)² = 1. If 60% of the alleles in a population are A (p = 0.6), then q = 0.4, and the expected genotype frequencies are 0.36 for AA, 0.48 for Aa, and 0.16 for aa. You only need one allele frequency to derive all three.

Interpreting the chi-square result

The Hardy-Weinberg equilibrium calculator estimates p and q from your observed data, uses them to generate expected genotype counts, and runs a chi-square test comparing expected and observed values. A significant chi-square result (conventionally p < 0.05) indicates that the observed genotype distribution does not match the equilibrium prediction. That mismatch suggests at least one of the five assumptions is being violated. Common causes include non-random mating such as inbreeding, selection against a particular genotype, or population stratification where the sample mixes subgroups with different allele frequencies, a situation called the Wahlund effect.

A non-significant result does not confirm the population is in true equilibrium. It means your sample lacks the statistical power to detect a deviation, or the deviation is genuinely small. Small datasets frequently fail to reject Hardy-Weinberg equilibrium even when violations are present, simply because there are not enough observations to reveal the pattern.

Limitations

The chi-square approximation becomes unreliable when expected counts in any genotype category fall below 5. For small samples, Fisher's exact test is more appropriate, but this calculator uses the chi-square approach. Hardy-Weinberg testing also applies to one locus at a time. Testing multiple loci independently does not account for linkage between them, and results from linked loci are not independent observations.

Frequently asked questions

What is Hardy-Weinberg equilibrium?

Hardy-Weinberg equilibrium is a null model in population genetics. It describes the genotype frequencies you would expect in a population where no evolutionary forces are acting and mating is random. Under these conditions, allele frequencies stay constant across generations and genotype frequencies follow the ratios p², 2pq, and q².

How do you calculate Hardy-Weinberg expected genotype frequencies?

Determine the allele frequencies p and q (where p + q = 1). Then compute the three expected genotype frequencies: p² for homozygous dominant, 2pq for heterozygous, and q² for homozygous recessive. Multiply each frequency by the total sample size to get the expected count for each genotype class.

How do you test for Hardy-Weinberg equilibrium?

Count the observed number of each genotype in your sample. Calculate expected counts from allele frequencies using the p², 2pq, q² ratios. Then run a chi-square test comparing observed to expected values. If the chi-square p-value is below 0.05, the observed distribution differs significantly from equilibrium expectations.

What does deviation from HWE mean?

A significant deviation means at least one Hardy-Weinberg assumption is probably violated. Common causes are non-random mating (such as inbreeding), natural selection acting on the locus, or population substructure mixing groups with different allele frequencies. It can also indicate genotyping errors in the dataset.

What is the difference between allele frequency and genotype frequency?

Allele frequency measures how common a specific allele is among all copies of that gene in the population (p + q = 1 for two alleles). Genotype frequency measures how common a specific genotype is among individuals (p² + 2pq + q² = 1). Allele frequency counts copies of a variant; genotype frequency counts individuals carrying a particular combination.