Hardy–Weinberg Equilibrium Calculator: Chi-Square and Exact Test
Enter the counts of the three genotypes (AA, AB and BB) and get the allele frequencies, the expected counts under Hardy–Weinberg equilibrium, a chi-square test and the exact test used in genome studies (Wigginton et al., 2005). Testing a whole SNP panel? Paste them all in batch mode.
- PriceFree, no login or sign-up needed
- Your dataProcessed in your browser, never uploaded
- Works onPhone, tablet or computer, any modern browser
- Made byDr. Muhammad Aammar Tufail, Codanics
- Published17 November 2026
- Last updated16 November 2026
📚 How to cite this tool
This tool is free. If it helped your thesis, paper, report or assignment, please cite it. It keeps the tools free and helps other students find them.
Tufail, M. A. (2026). Hardy–Weinberg equilibrium calculator: chi-square and exact test [Online tool]. Codanics. Retrieved 16 November 2026, from https://codanics.com/tools/hardy-weinberg-calculator/
In-text citation: (Tufail, 2026) · Narrative: Tufail (2026)
The access date is today’s date, filled in automatically. Author: Muhammad Aammar Tufail. Published 17 November 2026.
How to use the Hardy–Weinberg Equilibrium Calculator
- Type the two allele names (for example A, a or C, T) and the number of individuals with each genotype: homozygous for the first allele, heterozygous, and homozygous for the second allele.
- Click Test HWE. Read the allele frequencies, the expected counts and the exact test p-value. Use Yates’ correction only if your field expects it.
- For a SNP panel, open Many markers (batch), paste or upload a table of marker name, AA, AB and BB, and test them all at once with a Bonferroni threshold.
- Copy the results sentence or table, download the chart, or download the batch results as CSV.
What is Hardy–Weinberg equilibrium?
In a large, randomly mating population with no selection, mutation or migration, allele and genotype frequencies stay constant from generation to generation. If the allele frequencies are p and q (p + q = 1), the genotype frequencies are expected to be p², 2pq and q². Testing HWE checks whether your observed genotype counts fit these expectations.
Chi-square or exact test?
The chi-square test is an approximation that becomes unreliable when an expected count is small, which happens often with rare alleles. The exact test of Wigginton, Cutler and Abecasis (2005) calculates the probability of every possible number of heterozygotes given the allele counts and sums those as likely as, or less likely than, the observed one. It is the test used by PLINK and most genome-wide studies, and it is valid for any sample size. The mid-p version halves the probability of the observed table and is slightly less conservative.
Why test HWE?
- Genotyping quality control: markers far out of HWE in control samples often indicate genotyping errors, null alleles or copy-number variants.
- Population structure: a heterozygote deficit (F > 0) can mean inbreeding, assortative mating or a mixture of subpopulations (the Wahlund effect).
- Association studies: deviation in cases but not controls can support a true association.
Worked example
The classic MN blood-group data: MM = 1787, MN = 3039, NN = 1303 (n = 6129). p(M) = (2·1787 + 3039) / 12258 = 0.5395, so the expected counts are 1783.8, 3045.4 and 1299.8. χ²(1) = 0.027, p = .87, and the exact test gives p = .88: the population is in Hardy–Weinberg equilibrium.
How to report it
“Genotype frequencies of rs1001 (AA = 298, AB = 489, BB = 213) did not deviate from Hardy–Weinberg equilibrium (exact test, p = .66).” State which test you used, and for batch testing state the threshold.
References: Hardy GH (1908) Science 28:49 · Weinberg W (1908) · Wigginton JE, Cutler DJ, Abecasis GR (2005) Am J Hum Genet 76:887–893 · Graffelman J (2015) J Stat Softw 64(3), HardyWeinberg package · Graffelman J, Moreno V (2013) Stat Appl Genet Mol Biol 12:433 (mid-p).
Frequently asked questions
How do I calculate Hardy–Weinberg equilibrium?
Count the alleles to get p = (2·AA + AB) / 2n and q = 1 − p. The expected genotype counts are n·p², 2n·pq and n·q². Compare observed and expected with a chi-square test (1 df) or, better, the exact test. This calculator does all steps.
Why is there only 1 degree of freedom?
There are three genotype classes (3 − 1 = 2 df), but one more degree of freedom is lost because the allele frequency p is estimated from the same data, leaving 1 df.
Which p-value should I report?
Report the exact test p-value, especially if any expected count is below 5. The chi-square result is shown because many textbooks and older papers use it.
What does a significant HWE test mean?
That genotype frequencies differ from p², 2pq, q². Possible causes are genotyping errors, inbreeding, population structure, selection or non-random sampling. It does not tell you which one.
What is the inbreeding coefficient F?
F = 1 − observed heterozygosity / expected heterozygosity. Positive F means fewer heterozygotes than expected (inbreeding, null alleles, Wahlund effect); negative F means an excess of heterozygotes.
Can I test markers with more than two alleles?
This tool handles biallelic markers such as SNPs. For multiallelic microsatellites, use the population genetics calculator for heterozygosity and PIC, or software such as GenePop or Arlequin for multiallelic HWE tests.
Is my data uploaded?
No. All calculations run in your browser and nothing is uploaded or stored.
Do I need to log in or create an account to use the Hardy–Weinberg Equilibrium Calculator?
No. There is no login, no sign-up and no email required. Open the page and start using it straight away, for free, on any device.
How do I cite this tool in my thesis or paper?
Use the citation box on this page. In APA 7th edition: Tufail, M. A. (2026). Hardy–Weinberg equilibrium calculator: chi-square and exact test [Online tool]. Codanics. Retrieved [date you used it], from https://codanics.com/tools/hardy-weinberg-calculator/. BibTeX, RIS (EndNote, Mendeley, Zotero), MLA, Harvard, Chicago and Vancouver formats are also available.
Free guides and courses from Codanics
More free tools
See all free Codanics tools → · Codanics on YouTube · WhatsApp channel