Allele Frequency Calculator

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.

Calculate.co.nz is proud to be partnered with Health Based Building, a leader in sustainable and health-conscious building innovation. With over a century of experience, they develop high-performance systems like Foreverbreathe Specification, Magnum Board, and Foreverbreathe Paints to support energy-efficient, non-toxic living environments. Their commitment to healthier homes aligns with our belief that informed choices lead to better outcomes for Kiwi households.
Calculate.co.nz partner: Health Based Building
Standard method  Hardy-Weinberg principle (Hardy 1908; Weinberg 1908). Chi-square goodness-of-fit with 1 degree of freedom.

1. Observed Genotype Counts

2. Options

Allele Frequencies

Frequency p (A)
-
Dominant allele
Frequency q (a)
-
Recessive allele
Total individuals
-
Sampled
Total alleles (2N)
-
In gene pool sample

Observed vs Expected Genotypes

GenotypeObservedExpected (HWE)Freq (obs)

Hardy-Weinberg Test

p (freq. of A allele)-
q (freq. of a allele)-
p + q1.0000
Expected AA (p²)-
Expected Aa (2pq)-
Expected aa (q²)-
Chi-square statistic-
Degrees of freedom1
Critical value (α = 0.05)3.841
HWE conclusion-
Interpretation: Enter genotype counts above to see results.

How Allele Frequency is Calculated

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:

p = (2 x N_AA + N_Aa) / (2 x N_total)
q = 1 - p

where N_AA = count of AA individuals, N_Aa = count of Aa individuals, N_total = N_AA + N_Aa + N_aa

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.

Hardy-Weinberg Expected Genotype Frequencies

Under Hardy-Weinberg equilibrium, the expected frequencies of the three genotypes are determined entirely by the allele frequencies:

Expected frequency of AA = p²
Expected frequency of Aa = 2pq
Expected frequency of aa = q²

Expected count of AA = p² x N
Expected count of Aa = 2pq x N
Expected count of aa = q² x N

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.

Chi-Square Test for Hardy-Weinberg Equilibrium

The chi-square goodness-of-fit test compares observed genotype counts to HWE expected counts. The statistic is:

X² = sum of [(Observed - Expected)² / Expected]

X² = (O_AA - E_AA)² / E_AA + (O_Aa - E_Aa)² / E_Aa + (O_aa - E_aa)² / E_aa

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.

What Causes Departure from Hardy-Weinberg Equilibrium?

CauseEffect on genotype frequencies
Inbreeding / non-random matingExcess homozygotes (AA and aa), deficit of heterozygotes (Aa)
Positive assortative matingExcess homozygotes
Outbreeding / hybrid vigourExcess heterozygotes
Natural selection against a genotypeDeficit of the selected-against genotype
Recent migration or admixtureExcess heterozygotes (Wahlund effect reversed)
Wahlund effect (hidden subpopulations)Excess homozygotes
Genotyping errorOften excess homozygotes due to allele dropout

Worked Example

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:

  1. Total alleles = 2 x 500 = 1,000
  2. A alleles = (2 x 320) + 160 = 800; so p = 800/1,000 = 0.8000
  3. q = 1 - 0.8 = 0.2000
  4. Expected AA = 0.8² x 500 = 320.0
  5. Expected Aa = 2 x 0.8 x 0.2 x 500 = 160.0
  6. Expected aa = 0.2² x 500 = 20.0
  7. Chi-square = (320-320)²/320 + (160-160)²/160 + (20-20)²/20 = 0.000
  8. Conclusion: chi-square (0.000) is below the critical value of 3.841, so the locus is in HWE (p-value = 1.000).

The default inputs in this calculator are set to match this worked example exactly.

Related Calculators

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.