Hardy-Weinberg Equilibrium Calculator
Understand what this genetics calculator is actually telling you
The Hardy-Weinberg equilibrium model is one of the most useful starting points in population genetics because it gives you a clean null expectation for a single locus with two alleles. If a population is mating randomly and is not being pushed by strong evolutionary forces, genotype frequencies should settle into a predictable pattern: p2 for AA, 2pq for Aa, and q2 for aa. This calculator takes the genotype counts you observed in a sample, estimates the allele frequencies behind those counts, and then compares the observed sample with the equilibrium pattern you would expect from those allele frequencies.
That makes the tool practical in classrooms, lab exercises, field studies, and quick quality checks on genotype data. Instead of manually counting alleles, squaring proportions, and working through a chi-square test line by line, you can enter the three genotype counts and immediately see the estimated allele frequencies, the expected number of each genotype, and a summary statistic describing the gap between observed and expected values. The result does not prove why a population differs from equilibrium, but it does tell you whether your sample looks close to the classic Hardy-Weinberg pattern or whether it deserves a closer look.
What to enter in the form
The three inputs are counts of individuals, not percentages and not allele counts. AA Count is the number of sampled individuals with genotype A/A, Aa Count is the number with genotype A/a, and aa Count is the number with genotype a/a. Each person, plant, animal, or other sampled individual should be counted once in exactly one genotype category. If you already have genotype frequencies as percentages, convert them back to counts or work from the original sample size before using the form.
All three entries should be whole numbers for a single biallelic locus. In other words, the calculator assumes there are exactly two alleles at the locus, labeled A and a, and that the sample contains only the three diploid genotypes AA, Aa, and aa. If you are studying a locus with more than two alleles, a haploid organism, pooled allele data without genotype counts, or a marker with missing genotype classes, this calculator is not the right model. The math here is intentionally simple so that the interpretation stays clear.
The sample size is inferred automatically as N = AA + Aa + aa. That means there is no separate field for total population size. The calculator uses your sample counts as the observed data, estimates the allele frequencies from that sample, and then calculates the expected genotype counts for the same sample size. This is the common introductory Hardy-Weinberg workflow used in many genetics courses. If your sample contains related individuals, mixed subpopulations, or strong ascertainment bias, remember that the sample may not behave like a randomly drawn population, even if the arithmetic is correct.
The formula behind the result
The first step is to estimate allele frequencies from genotype counts. Every AA individual contributes two A alleles, every Aa individual contributes one A allele and one a allele, and every aa individual contributes two a alleles. Because there are two alleles per diploid individual, the total number of alleles in the sample is 2N. The frequency of allele A is called p, and the frequency of allele a is called q. In a two-allele system, p + q = 1.
Once p and q are known, Hardy-Weinberg equilibrium predicts genotype frequencies of p2, 2pq, and q2. The calculator multiplies those expected frequencies by your sample size N to produce the expected genotype counts. This is usually the most helpful comparison because your observations were entered as counts, not as proportions.
The final value reported is the chi-square statistic. It summarizes the size of the mismatch between what you observed and what Hardy-Weinberg equilibrium predicts. Larger mismatches produce larger chi-square values. A value near zero means the sample sits very close to the equilibrium expectation. In many textbook settings for a biallelic locus, the approximate degrees of freedom are treated as 1 because the allele frequency is estimated from the data. A common reference cutoff for 0.05 significance with 1 degree of freedom is 3.84, but that rule of thumb should be used cautiously and only with the usual assumptions in mind.
If you like to connect this genetics tool to a more general calculator mindset, the same structure still applies: inputs go into a function, the function produces outputs, and those outputs are easier to interpret when the model assumptions are made explicit. The generic MathML blocks below are preserved from the original document because they still describe the broad idea of turning inputs into a result.
Worked example
Suppose you sampled 100 individuals and observed 49 AA, 42 Aa, and 9 aa. The total sample size is 49 + 42 + 9 = 100. The estimated A allele frequency is p = (2ร49 + 42) / 200 = 140 / 200 = 0.70. That means the a allele frequency is q = 0.30. Under Hardy-Weinberg equilibrium, the expected genotype frequencies would therefore be 0.49 for AA, 0.42 for Aa, and 0.09 for aa.
Multiplying those frequencies by the sample size gives expected counts of 49 AA, 42 Aa, and 9 aa. In this example, the observed sample matches the equilibrium expectation exactly, so the chi-square statistic is 0.00. That is a nice teaching example because every step lands on a clean number, but real samples are usually messier. Even when a population is close to equilibrium, your counts will often differ a little because samples are finite, genotyping is imperfect, and biology is noisy.
Now imagine a second sample with the same size but more heterozygotes than expected, such as 40 AA, 50 Aa, and 10 aa. The estimated allele frequencies would still come from the counts you entered, but the expected genotype counts under equilibrium would no longer line up perfectly with the observations. The chi-square value would increase, and that would prompt the next question: is the deviation small enough to attribute to sampling variation, or large enough to suggest something more interesting, such as nonrandom mating, substructure, or selection?
How to interpret the output
The result panel returns five pieces of information in one line. First, it reports p and q, the estimated allele frequencies. Second, it reports the expected counts of AA, Aa, and aa under equilibrium. Third, it reports chi-square. Those expected counts are often the easiest values to reason about because they can be compared directly with the observed counts you entered. If your observed and expected numbers are close, the sample is behaving roughly the way the Hardy-Weinberg model predicts. If they are far apart, the sample is deviating from the model.
A small chi-square value should be read as evidence of closeness to the Hardy-Weinberg expectation, not as proof that every assumption is perfectly true. In the same way, a large chi-square value is a flag, not a diagnosis. A departure from equilibrium can arise because of natural selection, migration, inbreeding, assortative mating, mutation, genetic drift in a small population, population subdivision, or simple technical issues such as genotyping error. The statistic tells you that observed and expected counts differ more than usual, but it does not tell you which biological process caused that difference.
The expected counts themselves also deserve a quick sanity check. If any expected genotype count is zero, the usual chi-square calculation breaks down, and this page will warn you instead of reporting a misleading value. Even when expected counts are merely small rather than zero, the chi-square approximation can be weak. Many genetics references recommend caution when expected counts fall below about 5. In those cases, an exact test of Hardy-Weinberg equilibrium is often preferred over the rough chi-square approach used for quick screening.
Patterns that commonly appear in practice
When you compare observed and expected counts, it helps to look for the shape of the deviation rather than staring only at the final statistic. A heterozygote deficit means the observed Aa count is smaller than expected. A heterozygote excess means the observed Aa count is larger than expected. These patterns often point you toward the next biological or data-quality question to investigate.
| Observed pattern | What you see in the counts | Common interpretation to consider |
|---|---|---|
| Heterozygote deficit | Observed Aa is lower than 2pqN, with homozygotes higher than expected. | Could reflect inbreeding, assortative mating, population subdivision, or genotype-calling problems. |
| Heterozygote excess | Observed Aa is higher than expected, with one or both homozygotes reduced. | Could reflect disassortative mating, balancing selection, or occasional sampling fluctuation. |
| Unstable tiny sample | Counts are so small that one genotype class is rare or missing. | The chi-square approximation may be unreliable; consider exact methods or a larger sample. |
This table is not a list of firm conclusions. It is a guide to interpretation. The same mathematical deviation can have several biological explanations, and the correct explanation usually depends on study design, sampling strategy, and what you know about the population you are testing.
Assumptions behind Hardy-Weinberg equilibrium
The equilibrium model is intentionally idealized. It becomes useful because it gives you a stable baseline against which real populations can be compared. For the classic derivation to hold cleanly, the population is usually described as large, randomly mating, and free of strong evolutionary forces at the locus being studied. That does not mean real populations must be perfect before the calculator has value; it means departures from those assumptions help explain why observed counts might drift away from the expected pattern.
- Random mating: genotype frequencies are expected to reshuffle without systematic preference for similar or dissimilar mates at the locus.
- No selection at the locus: one genotype should not have a strong survival or reproductive advantage over the others.
- No migration: large influxes from populations with different allele frequencies can distort the expected proportions.
- No new mutation pressure of practical size: mutation is usually too weak to matter over one generation in simple classroom examples, but over longer time scales it can matter.
- Population large enough to limit drift: very small populations can wander away from equilibrium because of chance alone.
In addition, the chi-square interpretation assumes the sample is reasonably representative and that genotype calls are accurate. A beautifully calculated result can still be biologically misleading if the dataset contains hidden relatives, duplicated samples, missing calls coded inconsistently, or a mixture of distinct subpopulations. Those issues do not make the calculator wrong; they tell you the sample does not match the simple model as neatly as the formula assumes.
Common pitfalls and edge cases
The most common input mistake is entering allele counts instead of genotype counts. If you counted 140 A alleles and 60 a alleles, those are not valid entries for the AA, Aa, and aa boxes. Another common mistake is mixing data across loci or sampling times. Hardy-Weinberg calculations should be done for one locus and one clearly defined sample at a time. If you pool groups that differ substantially in allele frequency, you can create an apparent heterozygote deficit even when each subgroup is close to equilibrium on its own. That classic issue is part of why population structure matters so much in genetics.
Another pitfall is over-interpreting a single threshold. A chi-square value above a classroom cutoff does not automatically mean the population is evolving in a specific way, and a value below the cutoff does not guarantee biological perfection. Treat the number as a screening result. It tells you whether your sample looks ordinary under the null model or whether it stands out enough to justify more careful work. In advanced analyses, researchers often compute exact p-values, confidence intervals, or locus-wide multiple-testing corrections. This calculator stays intentionally lightweight so you can move quickly from raw counts to a grounded first interpretation.
Finally, note that all calculations happen in your browser. That makes the page convenient for teaching, transparent for auditing, and reasonably private for quick exploratory work with sample counts. You can inspect the code, copy the result text, and run examples without sending the entered numbers to a server-side calculator engine.
Result
Copy status messages appear here.
The result lists the estimated allele frequencies p and q, the expected AA, Aa, and aa counts under equilibrium, and the chi-square statistic comparing your sample with the Hardy-Weinberg expectation.
Mini-game: Gene Pool Drift Challenge
This optional arcade-style mini-game turns the same Hardy-Weinberg idea into a fast pattern-matching challenge. Tap drifting genotype orbs to build a sample, watch how each choice changes the current estimate of p, and then submit the sample when it is close to the target allele frequency. AA pushes p upward fastest because it contributes two A alleles, Aa nudges it halfway, and aa adds none of the A allele. The rules stay separate from the calculator above, so the game is purely for intuition and replayable practice.
Tip: the Submit Sample zone glows brighter when your current sample is close to the target p value.
