Hardy-Weinberg Equilibrium Calculator

This professional-grade calculator helps students, educators, and researchers compute allele frequencies (p and q), expected genotype frequencies and counts, and a chi-square test for Hardy–Weinberg equilibrium (HWE). It supports two input modes: observed genotype counts or a known allele frequency with sample size.

Calculator

Choose input mode

Observed genotype counts

Non-negative integer
Non-negative integer
Non-negative integer
Auto-summed from counts
Default: 5%. Used only when observed counts are provided.

Results

Allele frequency p (A)
Allele frequency q (a)
Expected AA (p²)
Expected Aa (2pq)
Expected aa (q²)
Expected counts (AA, Aa, aa)
Observed counts (AA, Aa, aa)
Chi-square χ² (df = 1)
p-value
Decision at α

Authoritative Content and Methodology

Data Source and Methodology

Primary sources:

  • G. H. Hardy (1908). “Mendelian Proportions in a Mixed Population.” Science, 28(706):49–50. doi: 10.1126/science.28.706.49
  • W. Weinberg (1908). “Über den Nachweis der Vererbung beim Menschen.” Jahreshefte des Vereins für vaterländische Naturkunde in Württemberg 64:368–382. (English translations available)
  • A. W. F. Edwards (2008). “G. H. Hardy (1908) and Hardy–Weinberg Equilibrium.” Genetics, 179(3):1143–1150. doi link

All expectations are computed from p and q under random mating. The hypothesis test is Pearson’s chi-square goodness-of-fit with 1 degree of freedom when p is estimated from the sample.

Tutti i calcoli si basano rigorosamente sulle formule e sui dati forniti da questa fonte.

The Formulas Explained

Allele frequencies from genotype counts:

$$ p = \frac{2 \cdot n_{AA} + n_{Aa}}{2N}, \quad q = 1 - p, \quad N = n_{AA} + n_{Aa} + n_{aa} $$

Expected genotype frequencies under HWE:

$$ P(AA) = p^2, \quad P(Aa) = 2pq, \quad P(aa) = q^2 $$

Expected counts (given N):

$$ E(AA) = N p^2,\quad E(Aa) = N \cdot 2pq,\quad E(aa) = N q^2 $$

Pearson chi-square test statistic:

$$ \chi^2 = \sum_{g \in \{AA,Aa,aa\}} \frac{(O_g - E_g)^2}{E_g}, \quad \text{df} = 1 \text{ when } p \text{ is estimated} $$

Glossary of Variables

  • AA, Aa, aa (Observed counts): Number of individuals with each genotype.
  • N: Total sample size, N = AA + Aa + aa.
  • p: Frequency of allele A; q: frequency of allele a; q = 1 − p.
  • Expected frequencies: p² (AA), 2pq (Aa), q² (aa).
  • Expected counts: N times the expected frequencies.
  • χ², p-value: Chi-square statistic and its p-value for testing HWE.
  • α: Significance level used to accept/reject the null hypothesis of HWE.

Come Funziona: Un Esempio Passo-Passo

Inputs: AA = 48, Aa = 32, aa = 20 (N = 100), α = 5%.

  1. Compute p and q: p = (2·48 + 32)/(2·100) = 128/200 = 0.64; q = 1 − 0.64 = 0.36.
  2. Expected frequencies: p² = 0.4096; 2pq = 0.4608; q² = 0.1296.
  3. Expected counts: E(AA) = 40.96; E(Aa) = 46.08; E(aa) = 12.96.
  4. Chi-square: χ² = (48−40.96)²/40.96 + (32−46.08)²/46.08 + (20−12.96)²/12.96 ≈ 7.50.
  5. With df = 1, p ≈ 0.006. Since p < 0.05, reject H0 (the sample deviates from HWE).

Frequently Asked Questions (FAQ)

What assumptions underlie HWE?

Random mating, infinitely large population (no drift), no selection, no mutation, and no migration.

Is χ² suitable for small expected counts?

When any expected count is below ~5, the chi-square approximation may be unreliable. Consider an exact test.

Can I supply only p and N to run the test?

No. You need observed genotype counts to compare against expectations.

Do you apply Yates’ continuity correction?

No. This calculator reports the uncorrected Pearson χ² (df = 1), commonly used in HWE screening.

Why don’t p and q change in allele-frequency mode?

In that mode, p is provided by you and q is computed as 1 − p; there are no observed counts to re-estimate p.

How many decimals are shown?

Frequencies to 4–6 decimals and counts to 2 decimals for readability.

Can this handle multiple alleles?

No. This tool focuses on a bi-allelic locus. Multiallelic HWE requires different formulas and degrees of freedom.

Strumento sviluppato da Ugo Candido,. Contenuti verificati da, CalcDomain Scientific Editorial Board.
Ultima revisione per l'accuratezza in data: .