Biology, Genetics & Clinical Lab Genetics & Heredity Hardy-Weinberg principle (Hardy 1908; Weinberg 1908)

Hardy-Weinberg Equilibrium Calculator

Enter how common a recessive phenotype is — as a frequency, as a "1 in N" incidence, or as the allele frequency itself — and this calculator returns the two allele frequencies p and q and the three expected genotype frequencies p2, 2pq and q2. It also gives the number most people actually want: how many silent heterozygous carriers there are for every affected person. For cystic fibrosis at roughly 1 affected birth in 2,500, that ratio is 98 carriers to 1.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
What you knowPick whichever number you have; the other two are derived from it.Frequency of the recessive phenotype (q²)
Recessive phenotype frequency (q²)The proportion of the population showing the recessive trait, as a decimal (0.0004 = 1 in 2,500).0.0004
Incidence: 1 affected inEnter the denominator of the published incidence, for example 2500 for 1 in 2,500 births.2500
Recessive allele frequency qUse this when a study reports the allele frequency itself rather than a phenotype count.0.02
Population size for expected countsHow many individuals to scale the expected genotype frequencies to; use your sample size.100000

It returns

  • Heterozygote (carrier) frequency, 2pq — The share of the population carrying one copy of the recessive allele without showing the trait.
  • That is one carrier in every — The reciprocal of 2pq — the familiar "1 in 25" style figure.
  • Recessive allele frequency q
  • Dominant allele frequency p
  • Homozygous dominant, p²
  • Homozygous recessive, q²
  • Carriers per affected individual — Equal to 2p ÷ q. It is what makes rare recessive alleles so persistent.
  • Expected carriers in your population

The formula

p2+2pq+q2=1
2pqq2=2pq

In plain text: p + q = 1 and p² + 2pq + q² = 1, with q = √(q²)

  • pFrequency of the dominant allele A (decimal)
  • qFrequency of the recessive allele a (decimal)
  • Expected frequency of the AA genotype (decimal)
  • 2pqExpected frequency of the Aa heterozygote (the carrier) (decimal)
  • Expected frequency of the aa genotype — the recessive phenotype (decimal)

Both statements are consequences of one assumption: gametes combine at random. p + q = 1 is bookkeeping over alleles; p² + 2pq + q² = 1 is the square of that bookkeeping, (p + q)² = 1.

Updated Category Genetics & Heredity Verified against published test cases Reading time 11 min

What the Hardy-Weinberg principle actually says

The Hardy-Weinberg principle states that in a large, randomly mating population with no selection, migration or new mutation, allele frequencies do not change from one generation to the next, and genotype frequencies settle in a single generation at p2 : 2pq : q2. G. H. Hardy and Wilhelm Weinberg published it independently in 1908, and it is the null model of population genetics — the baseline against which every interesting result is measured.

Its practical use is inversion. You almost never count genotypes directly for a recessive condition, because heterozygotes look exactly like homozygous dominants. What you can count is the recessive phenotype, and that frequency is q2. Take its square root and you have q; subtract from one and you have p; multiply and double and you have the carrier frequency 2pq, which is otherwise invisible.

That inversion is why a genetic counsellor can tell a patient with no family history that their chance of being a cystic fibrosis carrier is about 1 in 25. Nobody counted 25 people and found a carrier. Somebody counted affected births — roughly 1 in 2,500 among people of Northern European ancestry — and ran the square root.

Why the formula has the shape it has

Think of the gene pool as a bucket of alleles. If a fraction p of them are A and a fraction q are a, then p + q = 1 by definition — every allele is one or the other. Now form a zygote by drawing two alleles at random. The chance of drawing A twice is p × p. The chance of drawing a twice is q × q. The chance of one of each is p × q plus q × p, because A can arrive from either parent, which is where the factor of 2 in 2pq comes from. Students who lose that 2 have halved the carrier frequency.

Those three probabilities are exactly the terms of (p + q)2 = p2 + 2pq + q2 = 12 = 1. The equilibrium equation is nothing more than a binomial square, and the check that your three frequencies sum to 1 is a genuine check, not decoration.

The carriers-per-affected ratio falls straight out: 2pq ÷ q2 = 2p ÷ q. As q gets small, p approaches 1 and the ratio approaches 2 ÷ q. Halve the allele frequency and you double the number of carriers hiding behind each affected person. This single ratio explains why recessive disease alleles are so hard to remove from a population by selection against affected individuals: almost every copy of the allele is sitting in a heterozygote that selection cannot see.

One conversion trips people up more than any other: the square root goes on the phenotype frequency, not on the allele frequency. If a trait appears in 4% of a population, q2 = 0.04 and q = 0.20, not 0.04. Entering 0.04 into the allele-frequency field instead would report a carrier frequency of 7.7% rather than the correct 32%.

Worked example: a condition affecting 1 birth in 2,500

Take a recessive condition with an incidence of 1 in 2,500 live births, and scale the answer to a city of 100,000 people.

  1. Write the phenotype frequency. 1 ÷ 2,500 = 0.0004. This is q2, because only aa individuals show the trait.
  2. Take the square root. q = √0.0004 = 0.02.
  3. Get the other allele. p = 1 − 0.02 = 0.98.
  4. Homozygous dominant. p2 = 0.98 × 0.98 = 0.9604, or 96.04%.
  5. Carriers. 2pq = 2 × 0.98 × 0.02 = 0.0392, or 3.92%.
  6. Affected. q2 = 0.02 × 0.02 = 0.0004, or 0.04% — which returns the incidence you started from, as it must.
  7. Check the sum. 0.9604 + 0.0392 + 0.0004 = 1.0000. Exactly.
  8. Express carriers as 1 in N. 1 ÷ 0.0392 = 25.5, so about 1 person in 25 is a carrier.
  9. Carriers per affected person. 0.0392 ÷ 0.0004 = 98, which equals 2 × 0.98 ÷ 0.02.
  10. Scale to the city. 0.0392 × 100,000 = 3,920 carriers, against 0.0004 × 100,000 = 40 affected people.

Read the last two lines together. In a city of 100,000, forty people have the condition and nearly four thousand carry the allele without knowing it. Every one of those 3,920 people has a 1 in 25 chance that a randomly chosen partner is also a carrier, which is precisely the calculation behind population carrier screening.

How to read the numbers you get back

Start with q, not with the percentages. An allele frequency below about 0.05 marks a genuinely rare allele: heterozygotes outnumber affected homozygotes by 38 to 1 or more (2 × 0.95 ÷ 0.05 = 38). Between 0.05 and 0.3 you are in the range typical of common polymorphisms and of recessive conditions that reach appreciable frequency in specific populations. Above 0.5 the label "recessive" no longer implies "rare" — dominant and recessive describe how an allele behaves in a heterozygote, never how common it is.

The heterozygote frequency has a ceiling. 2pq is maximised at q = 0.5, where it equals 0.5 exactly, and it falls away symmetrically on both sides. No population in Hardy-Weinberg equilibrium can be more than half heterozygous at a two-allele locus. If observed heterozygosity in your sample exceeds 50%, either the locus has more than two alleles, or the sample is not in equilibrium — a bulk cross of two inbred lines does exactly this.

Treat a mismatch as information. When observed genotype counts depart from these expectations, the departure has named causes: non-random mating and inbreeding produce a heterozygote deficit; population structure (two subpopulations pooled) also produces a deficit, the Wahlund effect; genotyping error, particularly allele dropout, mimics both. Selection against homozygotes, or against heterozygotes, shifts things the other way. Quantify the mismatch with the genetics chi-square goodness-of-fit calculator, and measure the size of the heterozygote deficit or excess with the inbreeding coefficient reported by the allele frequency calculator.

Carrier frequency and carrier-to-affected ratio by disease incidence

Every row is q = √(incidence), 2pq = 2q(1 − q), and the ratio 2p/q. All values follow from the incidence in the first column.
Incidence (q²)qpCarrier frequency 2pqCarriers as 1 inCarriers per affected
1 in 1000.1000.90018.00%5.618
1 in 4000.0500.9509.50%10.538
1 in 1,6000.0250.9754.88%20.578
1 in 2,5000.0200.9803.92%25.598
1 in 10,0000.0100.9901.98%50.5198
1 in 40,0000.0050.9951.00%100.5398
1 in 250,0000.0020.9980.40%250.5998

The last column is always 2p/q, so it is close to 2/q for any rare allele. Rarer allele, more carriers per affected person.

Mistakes that produce a wrong carrier frequency

  • Square-rooting the wrong thing. The incidence of the recessive phenotype is q², so q is its square root. Taking the square root of an allele frequency that was already q is the single most common error.
  • Losing the factor of 2 in 2pq. Heterozygotes arise two ways — A from mother and a from father, or the reverse — so the frequency is 2pq, not pq.
  • Entering a percentage as a decimal fraction. A trait in 4% of people is q² = 0.04, giving q = 0.20. Typing 4 instead of 0.04 makes the calculation meaningless.
  • Assuming a dominant phenotype frequency is p. The dominant phenotype covers both AA and Aa, so its frequency is p² + 2pq = 1 − q². Get q from the recessive class and work backwards.
  • Applying one population's incidence to another. Allele frequencies differ substantially between ancestral populations, and a carrier risk quoted for one group does not transfer to another.
  • Using it on X-linked loci unchanged. Males carry one X, so the frequency of an X-linked recessive condition in males is q itself, not q². Females follow p² : 2pq : q².
  • Forgetting that several different pathogenic variants may exist at one locus. Screening panels detect a subset of them, so a negative screen lowers but does not eliminate carrier risk.

What the model assumes, and when it stops being true

Five assumptions carry the whole result: random mating with respect to the locus, no selection on any genotype, no migration, no mutation, and a population large enough that random sampling of gametes does not shift frequencies. Violate any of them and the expected genotype frequencies stop being expected.

In practice the assumptions fail gracefully. Selection against a rare recessive is extremely weak per generation, because so few copies of the allele are exposed to it — with q = 0.02, only 1 allele copy in 51 sits in an affected homozygote. Mutation rates at the scale of 10−5 or 10−6 per locus per generation are far too small to shift frequencies over the timescales you are working on. Population size matters only when it is genuinely small: drift dominates in the low hundreds, not in the tens of thousands.

The assumption that fails first, and most often, is random mating. Consanguineous marriage, assortative mating and population substructure all raise the homozygote frequencies above p² and q² and depress 2pq. For a couple who are first cousins, the appropriate risk calculation is not q² but F·q + (1 − F)·q², with F = 1/16 for first-cousin offspring: at q = 0.02 that gives 0.0625 × 0.02 + 0.9375 × 0.0004 = 0.00163, roughly four times the population baseline of 0.0004. Work the case-specific version through the autosomal recessive carrier risk calculator.

Finally, this calculator handles one locus with two alleles. For a Mendelian cross rather than a population, use the Punnett square probability calculator; for the number of distinct gametes a multi-locus genotype can make, the gamete combinations calculator; and for linked loci, the recombination frequency and map distance calculator.

Key terms

Allele frequency
The proportion of all copies of a gene in a population that are a particular variant. Written p and q for a two-allele locus, and p + q = 1.
Genotype frequency
The proportion of individuals with a given pair of alleles. Under Hardy-Weinberg these are p², 2pq and q².
Heterozygote (carrier)
An individual with one copy of each allele. For a fully recessive condition a carrier is clinically unaffected, which is what makes 2pq invisible to direct counting.
Penetrance
The proportion of individuals with a genotype who show the associated phenotype. Deriving q from disease incidence assumes penetrance is complete; if it is not, the true q is higher.
Wahlund effect
The deficit of heterozygotes seen when two or more subpopulations with different allele frequencies are pooled and analysed as one.
Fixation
The state in which one allele has frequency 1 and all others are lost. At fixation there are no heterozygotes and carrier ratios are undefined.

Frequently asked questions

How do I find carrier frequency from disease incidence?

Take the square root of the incidence to get q, subtract it from 1 to get p, then compute 2pq. For an incidence of 1 in 2,500: q = √0.0004 = 0.02, p = 0.98, and 2pq = 0.0392 — about 1 person in 25. The square root is the essential step, because the incidence you are given is already q², the frequency of the homozygous recessive genotype.

Why is the carrier frequency so much higher than the disease frequency?

Because the ratio between them is 2p/q, which becomes large as the allele becomes rare. At q = 0.02 there are 98 carriers for every affected person; at q = 0.005 there are 398. Almost every copy of a rare recessive allele sits in a heterozygote, where it produces no phenotype and is therefore invisible both to you and to natural selection.

What is a normal value for q?

There is no single normal value — q is a property of a specific allele in a specific population. As orientation: alleles causing recessive conditions that reach clinical notice usually sit below 0.05, common polymorphisms used in population genetics typically run between 0.05 and 0.5, and a q above 0.5 simply means the recessive allele is the majority allele at that locus. Compare within a population, never across.

Can I use Hardy-Weinberg for X-linked conditions?

Not without modification. Males have a single X chromosome, so the frequency of an X-linked recessive condition among males equals q directly, not q². Females follow the usual p² : 2pq : q² pattern, so affected females are far rarer than affected males — at q = 0.01, 1 male in 100 versus 1 female in 10,000. Enter the male incidence as q, not as q², if you are working from male prevalence data.

What does it mean if my observed counts do not match p², 2pq and q²?

It means at least one assumption is broken, and the direction of the mismatch narrows the list. A shortage of heterozygotes points to inbreeding, assortative mating, hidden population structure or allele dropout in genotyping. An excess of heterozygotes points to selection favouring them, to recent admixture between two differentiated groups, or to a genotyping artefact that miscalls homozygotes. Test the size of the departure formally rather than eyeballing it.

Does one generation of random mating really restore equilibrium?

Yes, for an autosomal locus with random mating — that is the striking part of the result. Whatever the starting genotype frequencies, after a single round of random mating the offspring genotype frequencies equal p², 2pq and q² computed from the parental allele frequencies, and they stay there. X-linked loci are the exception: they approach equilibrium over several generations, oscillating as they go, because males and females start with different allele frequencies.

How many people should I sample to estimate q reliably?

Enough that the rarest genotype class is not represented by a handful of individuals. For a rare recessive allele the homozygous class is vanishingly rare in any realistic sample, which is exactly why the standard practice is to estimate q from a published incidence rather than from your own genotype counts. When you do have genotype counts, the standard error of an allele frequency estimate is √(pq/2N), so quadrupling the sample halves the error.

Does a negative carrier screen mean my q-based risk no longer applies?

It lowers your risk but does not zero it, because no panel detects every pathogenic variant at a locus. If your prior carrier probability was 1 in 25 (4%) and the panel detects 90% of variants, your residual carrier risk is 0.04 × 0.10 ÷ (0.04 × 0.10 + 0.96) = 0.41%, roughly 1 in 240. The population figure this calculator returns is the prior; the screen result updates it.

References

  • Mendelian Proportions in a Mixed Population, Science 28:49-50 (1908) — G. H. Hardy
  • Principles of Population Genetics, 4th ed. — Hartl & Clark, Sinauer Associates
  • An Introduction to Genetic Analysis, 12th ed. — Griffiths, Wessler, Carroll & Doebley, W. H. Freeman
  • Cystic fibrosisMedlinePlus Genetics, U.S. National Library of Medicine