Hardy–Weinberg Equilibrium Calculator
Solve the Hardy–Weinberg relation p² + 2pq + q² = 1 for any of its three unknowns — the frequency of allele A, the frequency of allele a, or the heterozygote frequency 2pq — with step-by-step algebra, a live gamete-pool and Punnett-square schematic, and companion population-genetics metrics.
It is just a binomial expansion
Hardy–Weinberg equilibrium is the statement that (p + q)² = 1 expands to p² + 2pq + q² = 1. If gametes pair at random and the two alleles behave identically in transmission, the offspring genotype frequencies are the squared terms of the allele-frequency sum. Nothing more is required — no selection, no drift, no migration, no mutation, no non-random mating. Any departure from those frequencies signals that one of those assumptions is being violated.
It is a null model, not a law of nature
Real populations rarely sit exactly at Hardy–Weinberg equilibrium, and that is precisely the point. The equilibrium is the baseline against which observed genotype counts are compared. A χ² goodness-of-fit test against HWE answers a sharp question: given the allele frequencies actually present, are the genotype counts what random mating would produce? A significant deviation is evidence of inbreeding, population structure, selection, genotyping error, or assortative mating.
Heterozygosity peaks when alleles are equal
The function 2pq = 2p(1 − p) is a downward parabola with a maximum of 0.5 at p = q = 0.5. No biallelic locus can ever have more than 50% heterozygotes under Hardy–Weinberg equilibrium, no matter how the alleles are distributed. This gives a useful sanity check: a reported heterozygote frequency above 0.5 for a two-allele locus is impossible under HWE and points to a data or coding problem.
Rare recessive alleles hide in carriers
For a rare recessive allele with frequency q, the ratio of carriers to affected individuals is 2pq / q² ≈ 2/q. If q = 0.01, carriers outnumber affected homozygotes by roughly 200 to 1. This is why recessive disorders persist for many generations even under strong selection against homozygotes, and why carrier screening programmes target the heterozygous majority rather than the visibly affected minority.
How to Use This Calculator
The Hardy–Weinberg relation links three quantities: p, q and the heterozygote frequency 2pq. Pick which one the tool should solve, then supply the driver value.
1. Choose what to solve for
Select p, q or 2pq from the toggle. The calculator rearranges p² + 2pq + q² = 1 and p + q = 1 automatically for whichever quantity you pick.
2. Use realistic presets
Presets span the practical range: allele frequencies from 0.01 to 0.90, and heterozygote frequencies from 0.02 up to the theoretical maximum of 0.50 at p = q = 0.5.
3. Enter frequencies, not counts
All three fields are on a 0–1 scale. If you have raw genotype counts instead, scroll down to the genotype-count converter — it turns observed AA, Aa and aa counts into p, q, expected counts and a χ² test in one step.
4. Read the result and verdict
The result card shows the solved value together with its percentage form and the full genotype breakdown. A colour-coded verdict classifies the heterozygosity from near-monomorphic through to the theoretical maximum.
5. Check the schematic and charts
The schematic splits the gamete pool, shows the Punnett square, and draws the resulting offspring genotype bars. The chart plots p², 2pq and q² across the whole range of p, with your operating point marked.
6. Switch to Advanced for depth
Advanced mode adds a stacked genotype-composition chart, a sensitivity check on how heterozygosity responds to a change in p, and companion metrics including homozygosity, carrier-to-affected ratio and the p² : 2pq : q² ratio.
What This Tool Offers
Built around the Hardy–Weinberg relation p² + 2pq + q² = 1, the fundamental null model of population genetics.
Three-way solving
Solve for the A allele frequency p, the a allele frequency q, or the heterozygote frequency 2pq. The calculator rearranges the relation for whichever you choose.
Live Punnett schematic
A gamete pool split into p and q, a fully labelled Punnett square, and offspring genotype bars that resize as you drag the slider.
Heterozygosity verdict
Every result is classified from near-monomorphic through low, moderate and high heterozygosity up to the theoretical maximum of 2pq = 0.5 at p = q = 0.5.
Genotype-count converter
Paste observed AA, Aa and aa counts and get allele frequencies, expected genotype counts, a χ² statistic, a P-value and an automatic HWE verdict.
Dual visualisations
A curve chart of p², 2pq and q² across the full range of p, plus an advanced stacked-bar chart of genotype composition at five allele frequencies.
Reference tables
A full genotype-frequency lookup grid, real-world allele frequency examples from clinical genetics, and a complete variable reference table.
Reference Tables & Conversions
A genotype-count converter with an automatic Hardy–Weinberg test, a full genotype-frequency lookup grid, and representative allele frequencies from clinical genetics.
Genotype counts → allele frequencies & Hardy–Weinberg test
Genotype Frequency Lookup
Exact Hardy–Weinberg genotype frequencies across the full range of p. Carriers per affected is the ratio 2pq / q².
| p | q | AA = p² | Aa = 2pq | aa = q² | Carriers per affected |
|---|
Representative Allele Frequencies in Human Populations
Approximate allele frequencies for well-known variants, with the Hardy–Weinberg genotype frequencies they imply. Values are indicative and vary strongly between populations.
| Variant / trait | q (variant) | p | Affected q² | Carriers 2pq | 1 carrier in | Notes |
|---|
Variable Reference
| Symbol | Meaning | Typical range | Units |
|---|---|---|---|
| p | Frequency of allele A | 0 – 1 | dimensionless |
| q | Frequency of allele a | 0 – 1 | dimensionless |
| p² | Expected AA homozygote frequency | 0 – 1 | dimensionless |
| 2pq | Expected Aa heterozygote frequency | 0 – 0.5 | dimensionless |
| q² | Expected aa homozygote frequency | 0 – 1 | dimensionless |
| N | Number of individuals sampled | 1 – 10⁶ | count |
| χ² | Goodness-of-fit statistic vs. HWE | 0 – ∞ | dimensionless |
| FIS | Inbreeding coefficient within populations | −1 – 1 | dimensionless |
What Does p² + 2pq + q² = 1 Measure?
The Hardy–Weinberg relation describes the genotype frequencies expected at a single biallelic locus when a population is large, mates at random, and is not subject to selection, mutation, migration or drift. Under those conditions the allele frequencies do not change from one generation to the next, and the genotype frequencies settle into the fixed proportions p², 2pq and q². It is the simplest and most widely used null model in population genetics, and it underpins everything from clinical carrier screening to forensic DNA statistics.
Hardy–Weinberg Formula
The defining relationship is the expansion of the squared allele-frequency sum:
with the allele-frequency constraint:
Allele frequencies are recovered from genotype counts by counting gene copies:
q = (2·naa + nAa) / (2N)
And the deviation from equilibrium is tested with a χ² goodness-of-fit statistic on one degree of freedom:
Hardy–Weinberg Variables
| Symbol | Meaning | Notes |
|---|---|---|
| p | Frequency of allele A | Proportion of all gene copies at the locus that are A |
| q | Frequency of allele a | Equals 1 − p for a biallelic locus |
| p² | AA homozygote frequency | Probability that two randomly drawn gametes are both A |
| 2pq | Aa heterozygote frequency | Two equally likely orders: A then a, or a then A |
| q² | aa homozygote frequency | Probability that two randomly drawn gametes are both a |
| N | Sample size | Number of individuals genotyped |
| FIS | Inbreeding coefficient | Deficit of heterozygotes relative to HWE; FIS = 1 − Hobs/2pq |
How Each Variable Affects the Genotype Frequencies
Only one quantity actually varies at a biallelic locus: the allele frequency p. Everything else follows deterministically. As p moves from 0 to 1, the AA frequency p² rises monotonically from 0 to 1, the aa frequency q² falls monotonically from 1 to 0, and the heterozygote frequency 2pq traces a symmetric parabola that starts at 0, peaks at 0.5 when p = q = 0.5, and returns to 0. That single curve is the reason no biallelic locus under HWE can ever exceed 50% heterozygotes.
The practical consequence is that rare alleles are almost entirely hidden in heterozygotes. When q is small, q² becomes negligible while 2pq stays close to 2q, so the ratio of carriers to affected individuals is approximately 2/q. For a recessive disease allele at q = 0.02 — roughly the frequency of the common cystic fibrosis allele in northern Europe — the affected frequency is only 1 in 2,500, but about 1 in 25 people are carriers. The allele is essentially invisible in the phenotype and survives almost entirely in the heterozygous state.
Hardy–Weinberg Calculation Examples
q = 1 − 0.60 = 0.40
AA = p² = 0.60² = 0.360
Aa = 2pq = 2 × 0.60 × 0.40 = 0.480
aa = q² = 0.40² = 0.160
Check: 0.360 + 0.480 + 0.160 = 1.000
2p(1 − p) = 0.42 ⟹ p² − p + 0.21 = 0
p = [1 ± √(1 − 0.84)] / 2 = [1 ± 0.40] / 2
p = 0.70, q = 0.30 (or p = 0.30, q = 0.70 — the mirror solution)
p = (2×360 + 480) / 2,000 = 1,200 / 2,000 = 0.600
q = (2×160 + 480) / 2,000 = 800 / 2,000 = 0.400
Expected AA = 1,000 × 0.36 = 360.0, Aa = 1,000 × 0.48 = 480.0, aa = 1,000 × 0.16 = 160.0
χ² = 0.000 (df = 1), P = 1.000 ⟹ consistent with Hardy–Weinberg equilibrium
q = √(1/2,500) = 0.020, p = 0.980
Carrier frequency 2pq = 2 × 0.980 × 0.020 = 0.0392 ≈ 1 in 26
Carriers outnumber affected by 2pq / q² = 0.0392 / 0.0004 = 98 to 1
Frequently Asked Questions
Five conditions: the population is effectively infinite (so genetic drift is negligible), mating is random with respect to the locus, there is no selection acting on the alleles, there is no mutation, and there is no migration into or out of the population. When all five hold, allele frequencies stay constant across generations and genotype frequencies settle immediately into the p², 2pq, q² proportions — in fact a single generation of random mating is enough to reach them from any starting genotype distribution. The equilibrium is a null model: its value is that departures from it are informative, not that real populations satisfy it.
The function 2pq = 2p(1 − p) is a downward-opening parabola in p. Its derivative is 2 − 4p, which is zero at p = 0.5, and the second derivative is negative, so p = 0.5 is the global maximum. Substituting gives 2 × 0.5 × 0.5 = 0.5. Because p and q must sum to 1, the most balanced the allele frequencies can be is 50/50, and that is exactly when heterozygotes are most numerous. Any reported heterozygosity above 0.5 at a biallelic locus is mathematically impossible under HWE and usually indicates a data-entry error, a mis-specified locus, or a third allele being collapsed into one of the two.
Count gene copies rather than individuals. Every AA homozygote contributes two A alleles, every Aa heterozygote contributes one, and every aa homozygote contributes none, so p = (2·nAA + nAa) / (2N) where N is the total number of individuals. Similarly q = (2·naa + nAa) / (2N). The two must sum to 1, which is a useful arithmetic check. Once you have p, the expected Hardy–Weinberg genotype counts are simply N·p², N·2pq and N·q², and comparing them with the observed counts gives the χ² statistic. The converter card above performs the whole calculation for you.
A significant result (conventionally P < 0.05) means the observed genotype counts deviate from what random mating at the observed allele frequencies would produce. It does not tell you which assumption is violated. In practice the usual culprits are population structure (the sample mixes subpopulations with different allele frequencies, which produces a heterozygote deficit — the Wahlund effect), inbreeding or assortative mating (also a heterozygote deficit), genotyping error or null alleles (typically a heterozygote deficit), or heterozygote advantage and negative assortative mating (a heterozygote excess). Selection is often invoked but is rarely the simplest explanation; technical and demographic causes should be excluded first.
Because selection acts on phenotypes, not on alleles. A recessive allele in a heterozygote produces no disease phenotype, so it is invisible to selection and is passed on at the full Mendelian rate. Under Hardy–Weinberg, the ratio of carriers to affected individuals is 2pq / q² ≈ 2/q, so the rarer the allele, the more of it hides in heterozygotes. For a fully recessive lethal allele the equilibrium frequency under mutation–selection balance is q = √(μ/s), where μ is the mutation rate and s the selection coefficient against homozygotes. That square root is why even strongly deleterious recessive alleles settle at appreciable frequencies rather than being eliminated.
Yes. For k alleles with frequencies p₁, p₂, …, pk summing to 1, the genotype frequencies are the terms of the multinomial expansion of (p₁ + p₂ + … + pk)². A homozygote for allele i has frequency pi², and a heterozygote carrying alleles i and j has frequency 2pipj. The overall heterozygosity is 1 − Σpi², which for k equally frequent alleles equals (k − 1)/k. This calculator handles the biallelic case, which is by far the most common in clinical and teaching settings, but the same logic extends directly.
Inbreeding does not change allele frequencies, but it redistributes genotype frequencies away from heterozygotes and towards homozygotes. If F is the inbreeding coefficient, the genotype frequencies become AA = p² + F·pq, Aa = 2pq(1 − F) and aa = q² + F·pq. Setting F = 0 recovers Hardy–Weinberg exactly. The deficit of heterozygotes is directly measurable as FIS = 1 − Hobserved/2pq, which is why observed and expected heterozygosities are routinely compared in population-genetic studies. A positive FIS indicates a heterozygote deficit; a negative value indicates an excess.
Variables
| Symbol | Quantity | Unit |
|---|---|---|
| p | Dominant allele frequency | |
| q | Recessive allele frequency |
What it means
The Hardy‑Weinberg equilibrium principle states that allele and genotype frequencies in a population remain constant from generation to generation in the absence of evolutionary influences. For a gene with two alleles (A and a) with frequencies p and q (p + q = 1), the genotype frequencies are AA = p², Aa = 2pq, and aa = q². This provides a null model for detecting evolution; significant deviations indicate factors like selection, mutation, or genetic drift. It is widely used in population genetics to estimate allele frequencies, to study genetic disorders, and to assess the impact of non‑random mating. In conservation biology, it helps monitor genetic diversity. Understanding this law is essential for evolutionary biology, medicine (carrier frequencies), and forensic science.
Worked example
Hardy‑Weinberg Equilibrium – Two Detailed Examples
Real‑World| Parameter | Value |
|---|---|
| q (frequency of recessive allele) | 0.3 |
| Parameter | Value |
|---|---|
| q | 0.02 |
Common mistakes
- Allele frequencies: p and q represent the frequencies of the two alleles (p + q = 1). Ensure they sum to 1 before using.
- Genotype frequencies: p² (AA), 2pq (Aa), q² (aa) – they must sum to 1.
- Assumptions: Random mating, no mutation, no migration, no selection, large population – deviations affect equilibrium.
- Chi‑square test: Use to test if observed genotype frequencies differ significantly from expected.
- Multiple alleles: The formula extends to multiple alleles (p+q+r+...=1) – not just two.
Applications
The Hardy‑Weinberg equilibrium principle describes how allele and genotype frequencies remain constant in a population from generation to generation in the absence of evolutionary forces. The equation p² + 2pq + q² = 1 relates allele frequencies (p and q) to genotype frequencies for a single gene with two alleles. This is a foundational concept in population genetics, used to estimate carrier frequencies for recessive diseases, to test whether a population is evolving, and to study genetic diversity. Public health researchers use it to predict the prevalence of genetic disorders in populations. Conservation biologists apply it to monitor genetic health in endangered species. By understanding Hardy‑Weinberg equilibrium, professionals can assess the impact of migration, mutation, selection, and genetic drift on populations. It is a key tool in genetic counseling, epidemiology, and evolutionary biology.
- Estimation of carrier frequencies for recessive genetic diseases (e.g., cystic fibrosis)
- Testing for evolutionary forces (selection, drift, migration) in populations
- Genetic counseling and risk assessment for hereditary conditions
- Conservation genetics – monitoring genetic diversity in endangered species
- Population genetics research and education
Related calculators · Genetics
Recently updated formulas
Suggest an improvement
Found a mistake? Have a better example? Let us know.
You may send up to 3 suggestions per 24 hours.