Hardy–Weinberg Calculator
Calculate allele frequencies (p, q), expected genotype frequencies (p², 2pq, q²), and (optionally) a quick χ² check to compare observed vs expected genotype counts. Includes quick picks, sanity meter, and optional step-by-step.
Background
Under Hardy–Weinberg conditions (large population, random mating, no selection/migration/mutation/drift), allele frequencies p and q (where p + q = 1) predict genotype frequencies: AA = p², Aa = 2pq, aa = q². If you measured genotype counts, you can also compare observed vs expected with χ².
How to use this calculator
- Pick what you have: counts, allele frequency, or genotype frequencies.
- Enter values (and N if you want expected counts).
- Click Calculate. Turn on Step-by-step to see the exact math.
- If using counts, keep χ² checked to compare observed vs expected.
Quick tip: if your allele frequencies don’t add to 1 exactly (rounding), this tool will normalize.
How this calculator works
- Alleles → genotypes: AA=p², Aa=2pq, aa=q²
- Counts → alleles: p=(2AA+Aa)/(2N), q=1−p
- χ² check: χ²=Σ(O−E)²/E
Note: χ² is a quick check. In real bio/stats work, interpretation depends on assumptions, sample size, and how the test is taught in your course.
Formula & Equation Used
Hardy–Weinberg: p + q = 1
Expected genotype frequencies: p², 2pq, q²
Expected counts: E(AA)=Np², E(Aa)=N·2pq, E(aa)=Nq²
Allele freq from counts: p=(2AA+Aa)/(2N)
Chi-square: χ² = Σ (O − E)² / E
Example Problem & Step-by-Step Solution
Example 1 — genotype counts
Observed: AA=48, Aa=32, aa=20.
- Total N = 48 + 32 + 20 = 100
- p = (2·48 + 32)/(2·100)=0.64, q=0.36
- Expected freqs: p²=0.4096, 2pq=0.4608, q²=0.1296
Example 2 — allele frequency given
Given allele frequency p = 0.70 in a population of N = 200.
- Compute q = 1 − p = 1 − 0.70 = 0.30
- Expected genotype frequencies: AA = p² = 0.49, Aa = 2pq = 0.42, aa = q² = 0.09
- Expected genotype counts: AA = 200·0.49 = 98, Aa = 200·0.42 = 84, aa = 200·0.09 = 18
Example 3 — genotype frequencies (%)
Given genotype frequencies: AA = 40.96%, Aa = 46.08%, aa = 12.96% (sample size N = 250).
- Convert percentages to proportions: AA = 0.4096, Aa = 0.4608, aa = 0.1296
- Compute allele frequencies: p = AA + ½Aa = 0.4096 + 0.2304 = 0.64, q = 1 − p = 0.36
- Expected genotype frequencies: p² = 0.4096, 2pq = 0.4608, q² = 0.1296
- Expected counts: AA = 250·0.4096 = 102.4, Aa = 115.2, aa = 32.4
Frequently Asked Questions
Q: Do p and q have to add to 1?
Yes. If your inputs are slightly off due to rounding, we’ll normalize them.
Q: What does χ² tell me?
It measures how far observed counts are from Hardy–Weinberg expected counts. Bigger χ² means bigger deviation, but interpretation depends on your class conventions and assumptions.
Q: Can I compute expected counts without N?
You can always compute expected frequencies. Counts require a sample size N.