The Hardy-Weinberg principle is a cornerstone of population genetics. It describes how allele and genotype frequencies remain constant from generation to generation in an ideal population that is infinitely large, randomly mating, and unaffected by mutation, migration, or selection. Although no real population meets every condition perfectly, the principle provides a benchmark for detecting evolutionary forces at work. By comparing observed genetic data to the proportions predicted by Hardy-Weinberg, researchers can infer whether factors such as selection or gene flow are influencing allele distributions.
The foundation of the principle lies in the simple equation . Here represents the frequency of one allele, usually denoted A, and represents the frequency of another allele, usually denoted a. If there are only two alleles at a locus, their frequencies must sum to one. The equation predicts the proportions of genotypes AA, Aa, and aa as , , and respectively.
To apply this principle in practice, you can collect genotype counts from a sample and calculate allele frequencies. This calculator simplifies that process. Enter the number of individuals with each genotype—homozygous dominant (AA), heterozygous (Aa), and homozygous recessive (aa)—and click the calculate button. The script will compute allele frequencies and expected genotype counts in a population that is in equilibrium. It also performs a basic chi-square test to gauge how well your observations fit the Hardy-Weinberg expectations.
Internally, the script computes allele frequencies using:
and , where is the total number of individuals in the sample. The expected counts follow directly from multiplying the genotype proportions by . The chi-square statistic is calculated as:
summed across genotypes
where stands for observed counts and for expected counts. A large chi-square value suggests deviation from equilibrium.
When the chi-square statistic exceeds a critical value from the chi-square distribution with one degree of freedom (because allele frequencies are estimated from the data), the null hypothesis of Hardy-Weinberg equilibrium is rejected. In simpler terms, such a result means that at least one of the equilibrium assumptions is likely violated. Possible causes include natural selection favoring a particular genotype, non-random mating practices such as inbreeding or assortative mating, small population size leading to genetic drift, or migration introducing new alleles.
Even if your sample fits the predicted proportions, it does not prove the population meets every assumption perfectly. It simply indicates that there is no strong evidence of deviation with the available data. In practice, scientists use Hardy-Weinberg comparisons along with other information about a species' ecology, mating patterns, and history to draw conclusions about evolutionary forces.
Imagine researchers collecting data on a gene with two alleles, A and a, in a field population of wildflowers. They count 40 AA individuals, 40 Aa individuals, and 20 aa individuals. Entering these numbers into the calculator yields allele frequencies of 0.6 for A and 0.4 for a. The expected genotype counts are 36 AA, 48 Aa, and 16 aa. The chi-square statistic comes out to 2.22, which falls below the critical value of 3.84 for a 5% significance level. In this case, the sample does not provide strong evidence against Hardy-Weinberg equilibrium. However, if the observed counts were 60 AA, 20 Aa, and 20 aa, the chi-square would be 16.67—far above the critical value—indicating a significant departure likely due to selection or inbreeding.
The principle is named after the English mathematician G. H. Hardy and the German physician Wilhelm Weinberg, who independently formulated it in 1908. Both were responding to misunderstandings about how a dominant allele might increase in frequency simply because it is expressed. They demonstrated mathematically that allele frequencies remain stable from generation to generation in the absence of evolutionary forces. This insight laid the groundwork for modern population genetics.
Today, the Hardy-Weinberg model helps interpret genetic surveys of both natural populations and human groups. Medical researchers use it to predict carrier frequencies for inherited diseases, while conservation biologists monitor whether rare alleles are being lost in endangered species. Forensic scientists apply the principle to estimate match probabilities when analyzing DNA evidence. Even in agriculture, plant and animal breeders track allele frequencies to maintain genetic diversity in breeding programs.
Because real populations rarely match all Hardy-Weinberg assumptions, the principle is best viewed as a null model. Deviations point to interesting evolutionary phenomena worth studying further. A locus under strong selection may show genotype distributions far from the predicted , , pattern. A small, isolated group might display high levels of homozygosity due to genetic drift, while migrants introducing new alleles can shift frequencies over time.
Keeping the computation entirely in your browser ensures privacy and transparency. None of your genetic data, whether from research or class exercises, is transmitted to any server. You can review the JavaScript code yourself to understand exactly how the calculations are performed. Because it runs offline, the calculator is also a handy teaching aid in locations without reliable internet access or when you wish to modify it for custom class assignments.
The Hardy-Weinberg Equilibrium Calculator provides a convenient way to explore the relationship between allele frequencies and genotype distributions. By entering simple counts, you gain insight into whether a population may be evolving under non-random mating, selection, or other forces. The results should prompt further investigation rather than final judgment, but they offer a window into the hidden genetic structure shaping every species. With this tool, students and researchers alike can experiment with hypothetical scenarios, test class data, or analyze real-world collections—all without leaving the page.
Calculate theoretical firing rates of neurons based on refractory period and observation time.
Evaluate a bank's capital adequacy ratio using Tier 1 and Tier 2 capital with risk-weighted assets.
Calculate the expected shortfall (CVaR) of an investment portfolio using volatility, mean return, and a chosen confidence level.