Biology Free & Verified

Hardy-Weinberg Calculator

Calculate allele and genotype frequencies (p, q, p², 2pq, q²) with our free Hardy-Weinberg Calculator. Perform automated Chi-Square (χ²) goodness-of-fit testing, carrier frequency calculations, tri-allelic ABO blood systems, and natural selection modeling.

Rate this tool

Hardy-Weinberg Calculator — Equilibrium & Chi-Square (χ²) Solver

Compute population allele frequencies ($p, q$), carrier rates ($2pq$), and genotype distributions. Perform statistical Chi-Square ($\chi^2$) Goodness-of-Fit tests on empirical population counts, test tri-allelic ABO blood systems, and model natural selection dynamics.

Biostatistical χ² Goodness-of-Fit
Population Case Studies:

Calculate carrier frequency and genotype proportions from p, q, or q².

Converts frequencies to expected headcount in a population.

Select which variable is known from your genetic data.

Enter a probability between 0 and 1 (e.g., 0.20 = 20%).

Population Genetics & Biostatistics Guide

The Hardy-Weinberg Principle: Mathematics, Evolutionary Forces & Chi-Square Testing

A comprehensive reference explaining population allele and genotype frequencies, carrier risk estimations, degrees of freedom, the Chi-Square ($\chi^2$) goodness-of-fit test, and mathematical modeling of natural selection.

What is Hardy-Weinberg Equilibrium?

Formulated independently in 1908 by English mathematician Godfrey Harold Hardy and German physician Wilhelm Weinberg, the Hardy-Weinberg Principle is the foundational null hypothesis of modern population genetics and evolutionary biology. It states that allele and genotype frequencies in a sexually reproducing, diploid population remain constant (in equilibrium) from generation to generation in the absence of evolutionary influences.

The principle functions as a scientific baseline. Just as Newton's First Law describes an object's motion in the absence of friction, Hardy-Weinberg equilibrium describes a gene pool when no evolutionary forces are operating. When observed population data statistically deviates from Hardy-Weinberg expectations, researchers know that evolution is actively occurring.

The 5 Mandatory Assumptions for Hardy-Weinberg Equilibrium:
  • No Natural Selection: All genotypes possess equal reproductive fitness and survival rates ($w = 1.0$).
  • No Mutation: No novel alleles are introduced through genomic mutations ($\mu = 0$).
  • No Gene Flow / Migration: The population is completely closed; no individuals enter or leave ($m = 0$).
  • Infinitely Large Population: The population size is vast enough that random genetic drift has negligible effect.
  • Random Mating (Panmixia): Mating occurs strictly by chance with respect to the gene locus, without sexual selection or inbreeding.

Governing Mathematical Equations

For a diploid autosomal locus with two alleles—a dominant allele $A$ and a recessive allele $a$—we define their frequencies in the gene pool as $p$ and $q$, respectively:

$$\text{Allele Frequency Identity:}\quad p + q = 1$$
$$\text{Genotype Frequency Expansion:}\quad (p + q)^2 = p^2 + 2pq + q^2 = 1$$
$$\text{Chi-Square Statistic:}\quad \chi^2 = \sum \frac{(O - E)^2}{E},\quad df = k - 1 - m = 3 - 1 - 1 = 1$$
Parameter Symbol Mathematical Definition Biological Interpretation
Dominant Allele Frequency p $p = \text{Freq}(A) = \frac{2N_{AA} + N_{Aa}}{2N}$ Proportion of all gametes carrying the dominant allele.
Recessive Allele Frequency q $q = \text{Freq}(a) = \frac{2N_{aa} + N_{Aa}}{2N}$ Proportion of all gametes carrying the recessive allele ($q = 1 - p$).
Homozygous Dominant p² $\text{Freq}(AA) = p \times p$ Proportion of population with two dominant alleles.
Heterozygous Carriers 2pq $\text{Freq}(Aa) = 2 \times p \times q$ Asymptomatic disease carriers; prevalence $= 1 / 2pq$.
Homozygous Recessive q² $\text{Freq}(aa) = q \times q$ Affected individuals expressing the recessive clinical phenotype.

Step-by-Step Worked Real-World Examples

Example 1: Clinical Genetics Carrier Screening (Cystic Fibrosis) Medical Genetics

Cystic Fibrosis is an autosomal recessive disorder affecting approximately 1 in 2,500 newborns in populations of Northern European descent ($q^2 = 1/2500 = 0.0004$). How many individuals in this population are healthy carriers?

  1. Find Recessive Allele Frequency: $q = \sqrt{q^2} = \sqrt{0.0004} = 0.02$ ($2\%$).
  2. Find Dominant Allele Frequency: $p = 1 - q = 1 - 0.02 = 0.98$ ($98\%$).
  3. Calculate Carrier Frequency: $2pq = 2 \times 0.98 \times 0.02 = 0.0392 \approx 3.92\%$.
  4. Determine Carrier Prevalence: $\text{Prevalence} = 1 / 0.0392 \approx \text{1 in every 25.5 people}$.
Clinical Insight: While only 1 in 2,500 people has the disease, nearly 1 in 25 individuals is an asymptomatic carrier capable of transmitting the pathogenic CFTR mutation.
Example 2: Population Sample Chi-Square (χ²) Testing Biostatistical Testing

A field ecologist captures $N = 1000$ butterflies and genotypes a wing pattern locus: $490\ AA$, $420\ Aa$, and $90\ aa$. Is this wild population in Hardy-Weinberg equilibrium?

  1. Total Alleles: $2 \times 1000 = 2000$. Count $A = 2(490) + 420 = 1400 \implies p = 1400/2000 = 0.70$.
  2. Count a: $2(90) + 420 = 600 \implies q = 600/2000 = 0.30$.
  3. Expected Numbers: $E(AA) = (0.7)^2 \times 1000 = 490$. $E(Aa) = 2(0.7)(0.3) \times 1000 = 420$. $E(aa) = (0.3)^2 \times 1000 = 90$.
  4. Chi-Square: $\chi^2 = \frac{(490-490)^2}{490} + \frac{(420-420)^2}{420} + \frac{(90-90)^2}{90} = 0.00$.
  5. Statistical Verdict: At $df = 1$, critical value for $\alpha = 0.05$ is $3.841$. Since $\chi^2 = 0.00 \le 3.841$ ($p = 1.0$), we fail to reject the null hypothesis. The butterfly population is in perfect genetic equilibrium.

Chi-Square Critical Value Benchmarks (df = 1)

In Hardy-Weinberg testing for 2 alleles across 3 genotypes, the degrees of freedom is strictly $df = 1$ ($k - 1 - m = 3 - 1 - 1 = 1$). Use this reference table to evaluate test statistics:

Significance Level (α) Critical Value (χ²_crit) Confidence Level Statistical Decision
α = 0.10 2.706 90% Confidence Reject $H_0$ if $\chi^2 > 2.706$ (Marginal evidence)
α = 0.05 (Standard) 3.841 95% Confidence Standard biological threshold: $\chi^2 > 3.841 \implies$ Significant Evolution
α = 0.01 6.635 99% Confidence Highly significant deviation ($\chi^2 > 6.635$)
α = 0.001 10.828 99.9% Confidence Extremely strong evidence of active selection or assortative mating

Population Genetics Pitfalls to Avoid

Degrees of Freedom is 1, NOT 2

A widespread student error is setting $df = 3 - 1 = 2$. However, because allele frequency $p$ was estimated directly from the sample data before calculating expected values, one additional degree of freedom is consumed: $df = k - 1 - m = 3 - 1 - 1 = 1$.

Never Assume Equilibrium Blindly

You cannot calculate $p = \sqrt{p^2}$ unless the population is already known to be in equilibrium. When observed counts ($N_{AA}, N_{Aa}, N_{aa}$) are provided, always count alleles directly ($p = \frac{2N_{AA} + N_{Aa}}{2N}$) rather than taking square roots.

Frequently Asked Questions

What causes a population to deviate from Hardy-Weinberg equilibrium?

Any violation of the 5 core assumptions causes deviation: natural selection favoring one genotype, non-random mating (such as inbreeding or sexual selection), gene flow (immigration/emigration of alleles), genetic drift in small populations, or de novo mutations.

How does the 3-allele ABO blood group expansion work?

The ABO locus has three alleles: $I^A$ ($p$), $I^B$ ($q$), and $i$ ($r$), with $p + q + r = 1$. The expansion $(p+q+r)^2 = 1$ yields 6 genotypes producing 4 blood types: Type A ($p^2 + 2pr$), Type B ($q^2 + 2qr$), Type AB ($2pq$), and Type O ($r^2$).

Why is carrier frequency (2pq) highest when p = q = 0.50?

Mathematically, the product $2p(1-p) = 2p - 2p^2$ reaches its maximum value when its first derivative $2 - 4p = 0 \implies p = 0.5$. At this point, heterozygote carriers reach their maximum theoretical ceiling of 50% ($2pq = 2 \times 0.5 \times 0.5 = 0.50$).