Calculate allele frequencies p and q from observed genotype counts for a two-allele locus. Enter the number of individuals with each genotype (AA, Aa, aa) and the calculator shows allele frequencies, expected Hardy-Weinberg genotype frequencies, and a chi-square test for deviation from HWE.
| Genotype | Observed | Expected (HWE) | Freq (obs) |
|---|
At a locus with two alleles, A (dominant) and a (recessive), each individual carries exactly two copies. The frequency of allele A (denoted p) is the proportion of all allele copies in the sample that are A:
The denominator is 2 x N_total because each individual carries two alleles. For example, if you have 320 AA, 160 Aa, and 20 aa individuals (total = 500), the total number of alleles is 1,000. The A alleles are: (2 x 320) + 160 = 800, so p = 800 / 1,000 = 0.8. Then q = 1 - 0.8 = 0.2.
Under Hardy-Weinberg equilibrium, the expected frequencies of the three genotypes are determined entirely by the allele frequencies:
In the worked example (320 AA, 160 Aa, 20 aa; N = 500; p = 0.8; q = 0.2): expected AA = 0.64 x 500 = 320; expected Aa = 2 x 0.8 x 0.2 x 500 = 160; expected aa = 0.04 x 500 = 20. The observed counts match the HWE expected counts exactly in this example, giving a chi-square of 0 and a non-significant HWE test.
The chi-square goodness-of-fit test compares observed genotype counts to HWE expected counts. The statistic is:
The degrees of freedom for the HWE test is 1 (three genotype classes minus one allele frequency estimated from the data minus one constraint that frequencies sum to 1, giving 3 - 1 - 1 = 1). At a significance level of 0.05, the critical value is 3.841. If the chi-square exceeds this threshold, the population departs significantly from HWE at the chosen significance level.
The chi-square test is only reliable when expected counts are at least 5 for each genotype class. With small samples, Fisher's exact test or a permutation test is preferable.
| Cause | Effect on genotype frequencies |
|---|---|
| Inbreeding / non-random mating | Excess homozygotes (AA and aa), deficit of heterozygotes (Aa) |
| Positive assortative mating | Excess homozygotes |
| Outbreeding / hybrid vigour | Excess heterozygotes |
| Natural selection against a genotype | Deficit of the selected-against genotype |
| Recent migration or admixture | Excess heterozygotes (Wahlund effect reversed) |
| Wahlund effect (hidden subpopulations) | Excess homozygotes |
| Genotyping error | Often excess homozygotes due to allele dropout |
A researcher genotypes 500 individuals at a single nucleotide polymorphism (SNP) and finds: AA = 320, Aa = 160, aa = 20. To test whether this SNP locus is in Hardy-Weinberg equilibrium:
The default inputs in this calculator are set to match this worked example exactly.
Sources and method: Hardy GH (1908) "Mendelian proportions in a mixed population." Science 28:49-50. Weinberg W (1908) "Uber den Nachweis der Vererbung beim Menschen." Jahreshefte des Vereins fur vaterlandische Naturkunde in Wurttemberg 64:368-382. Chi-square critical value from standard chi-square distribution table (df = 1). Guo SW, Thompson EA (1992) "Performing the exact test of Hardy-Weinberg proportion for multiple alleles." Biometrics 48:361-372.
This calculator is for educational and research planning purposes. The chi-square test for HWE requires expected counts of at least 5 per genotype class. For small samples, use Fisher's exact test. Always consult a statistician or geneticist for formal population genetics analyses.
If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.
Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.
Calculate.co.nz is the sister site of CalculatorHub.com, the world's largest calculator website by tool count.
All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.
Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.
Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.
Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.
All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.
About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use
Reviewed and maintained. Last reviewed 2026-07-02 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.
© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.