Chi-Square Calculator for Genetic Ratios
Test offspring counts against 3:1, 1:1, 1:2:1, 9:3:3:1, 1:1:1:1 or Hardy-Weinberg with a chi-square goodness-of-fit test; degrees of freedom are set for you.
Chi-Square Calculator for Genetic Ratios
Background.
Mendel scored 556 seeds from his dihybrid pea cross: 315 round and yellow, 108 round and green, 101 wrinkled and yellow, 32 wrinkled and green. A perfect 9:3:3:1 split of 556 would have been 312.75, 104.25, 104.25 and 34.75. Real crosses never land exactly on the ratio, so the useful question is whether the miss is the sort that random sampling produces on its own, or big enough to make you doubt the hypothesis — and start looking for linkage, a lethal genotype, poor survival of one class or a scoring mistake.
The chi-square goodness-of-fit test turns that question into a number. Each class contributes its squared excess or shortfall divided by the count expected, and the total is compared with the chi-square distribution for the right number of degrees of freedom. That last number is where most errors creep in. For a fixed Mendelian ratio it is the number of classes minus one, but a Hardy-Weinberg test loses a second degree of freedom because the allele frequency is estimated from the very counts being tested. Choosing the ratio here sets the degrees of freedom for you.
Six hypotheses are available: 3:1 and 1:2:1 for monohybrid crosses, 1:1 and 1:1:1:1 for testcrosses, 9:3:3:1 for a dihybrid F2, and Hardy-Weinberg proportions for genotype counts sampled from a population. Alongside the statistic you get the degrees of freedom, the p-value, the critical value at your chosen significance level, the smallest expected count so you can judge whether the approximation holds, and a verdict worded no more strongly than the test allows.
What is chi-square calculator for genetic ratios?
A goodness-of-fit test asks whether counts falling into categories match proportions fixed in advance. The statistic, χ² = Σ (O − E)² ÷ E, is zero for a perfect fit and grows as the fit worsens; squaring makes excesses and shortfalls count alike, and dividing by E means a miss of 10 weighs far more in a class expecting 20 than in one expecting 2,000. If the hypothesis is true, the statistic follows a chi-square distribution approximately, and the p-value is the chance of a value at least as large. In genetics the expected counts come from a segregation ratio, or, for a population sample, from the Hardy-Weinberg proportions p², 2pq and q².
How to use this calculator.
- Pick the ratio your hypothesis predicts. The choice also fixes the degrees of freedom, so there is nothing to look up.
- Enter whole-number counts in ratio order. For 9:3:3:1 put the double-dominant class first, the two single-dominant classes next in either order (they share an expected count), and the double-recessive last; for 1:2:1 and Hardy-Weinberg enter AA, Aa, then aa. Fields a ratio does not use are ignored.
- Choose the significance level before you look at the result; switching from 0.05 to 0.10 because a test came close defeats its purpose.
- Read the verdict, then the smallest expected count. Below 5 the verdict adds a caution that the p-value is only approximate.
- For Hardy-Weinberg tests on genotyping data with a rare allele, confirm a borderline result with an exact test, and remember that a strong departure at a single marker is routinely checked as possible genotyping error before it is read as biology.
The formula.
Expected counts first: each class receives the total N times its share of the ratio, so for 9:3:3:1 the shares are 9/16, 3/16, 3/16 and 1/16. They are not rounded to whole individuals, since rounding them shifts the statistic. Then χ² = Σ (O − E)² ÷ E over the classes. NIST's handbook gives the degrees of freedom as k − c, where k is the number of classes and c is one plus the number of parameters estimated from the data. The one is the constraint that expected counts must add up to the observed total. A fixed Mendelian ratio estimates nothing, so df = k − 1: 1 for 3:1 and 1:1, 2 for 1:2:1, 3 for 9:3:3:1 and 1:1:1:1. In Hardy-Weinberg mode the allele frequency is estimated by gene counting, p = (2 × AA + Aa) ÷ 2N, expected counts are p²N, 2pqN and q²N, and df = 3 − 2 = 1. The critical value is the point of the chi-square distribution cutting off an upper tail of size alpha, worked out from the distribution itself; at 0.05 it is 3.841 for 1 df, 5.991 for 2 and 7.815 for 3, matching NIST's printed table. The hypothesis is rejected when χ² exceeds that value, which always coincides with the p-value falling below alpha. Counts must be whole and non-negative with a total above zero, and a Hardy-Weinberg sample containing only one allele is refused because there is nothing to test.
A worked example.
Mendel's 556 seeds give expected counts of 556 × 9/16 = 312.75 round and yellow, 556 × 3/16 = 104.25 for each single-dominant class, and 556 × 1/16 = 34.75 wrinkled and green. Class by class: (315 − 312.75)² ÷ 312.75 = 5.0625 ÷ 312.75 = 0.0162; (108 − 104.25)² ÷ 104.25 = 14.0625 ÷ 104.25 = 0.1349; (101 − 104.25)² ÷ 104.25 = 10.5625 ÷ 104.25 = 0.1013; (32 − 34.75)² ÷ 34.75 = 7.5625 ÷ 34.75 = 0.2176. The sum is χ² = 0.4700. Four classes with nothing estimated give 4 − 1 = 3 degrees of freedom, and the critical value at alpha 0.05 is 7.8147. The statistic falls far short of it, so the 9:3:3:1 hypothesis is not rejected; the p-value of 0.9254 means that a departure at least this large would turn up about 93% of the time by chance alone if the ratio were exactly right. Notice which class contributes most: the wrinkled green seeds, missing their expectation by only 2.75, outweigh the round yellow seeds that missed by 2.25, because a deviation counts relative to the size of the class it occurs in.
Frequently asked questions.
Why does a Hardy-Weinberg chi-square test have only 1 degree of freedom?
My counts are close to 3:1, so why does the test reject?
What could cause a significant departure from the expected ratio?
How small can the expected counts be?
With only 20 offspring, can the test tell 3:1 from 1:1?
Were Mendel's results too good to be true?
References& sources.
- [1]NIST/SEMATECH (2012). e-Handbook of Statistical Methods, §1.3.5.15 'Chi-Square Goodness-of-Fit Test'. Source for the test statistic χ² = Σ(O−E)²/E, for the degrees-of-freedom rule k − c where c is the number of estimated parameters plus one, and for the rejection rule χ² > χ²₁₋α,k₋c. Independent, free, US National Institute of Standards and Technology; retrieved 2026-07-29.
- [2]NIST/SEMATECH (2012). e-Handbook of Statistical Methods, §1.3.6.7.4 'Critical Values of the Chi-Square Distribution'. Used as the independent check on this page's arithmetic: no critical value is taken from a table here, and the computed values reproduce all nine table entries for 1 to 3 degrees of freedom at probability levels 0.90, 0.95 and 0.99 — 2.706 / 3.841 / 6.635, 4.605 / 5.991 / 9.210 and 6.251 / 7.815 / 11.345. Independent, free, NIST; retrieved 2026-07-29.
- [3]Abbott, S. & Fairbanks, D. J. (2016). Experiments on plant hybrids by Gregor Mendel. Genetics 204(2):407–422, doi:10.1534/genetics.116.195198. PMC5068836. An annotated modern English translation of Mendel's 1866 paper, and the source of both worked examples on this page: the dihybrid F2 counts (556 seeds; 315 round and yellow, 101 angular and yellow, 108 round and green, 32 angular and green) and the monohybrid stem-length counts (1,064 plants; 787 long, 277 short). Independent, free via PubMed Central; retrieved 2026-07-29.
- [4]NCBI dbSNP FAQ Archive, 'Hardy Weinberg Equilibrium Data'. NCBI Bookshelf NBK573517. Corroborates the degrees-of-freedom rule used by the Hardy-Weinberg mode — recording the argument that because only one independent parameter is being estimated there should only be 1 degree of freedom — and records NCBI's stated intention to move from the chi-square test to Fisher's exact test because the latter is a better way to assess Hardy-Weinberg proportions when the sample size is small. Independent, free, US National Institutes of Health; retrieved 2026-07-29.
- [5]Wigginton, J. E., Cutler, D. J. & Abecasis, G. R. (2005). A note on exact tests of Hardy-Weinberg equilibrium. American Journal of Human Genetics 76(5):887–893. PubMed 15789306. Source of the caveat attached to the Hardy-Weinberg mode: the chi-square goodness-of-fit test can have inflated type I error rates even in relatively large samples — for example 1,000 individuals containing about 100 copies of the minor allele — and an exact test should be preferred there. Independent; abstract free on PubMed, full text paywalled at the publisher; retrieved 2026-07-29.
- [6]Cochran, W. G. (1954). Some methods for strengthening the common χ² tests. Biometrics 10(4):417–451, doi:10.2307/3001616. The origin of the minimum-expected-count rule of thumb that this page reports and cautions on. Note that the rule circulates in several incompatible forms — expected counts of at least 5, of at least 10, or at least 5 in 80 % of cells with none below 1 — and NIST's goodness-of-fit section states no minimum at all. Independent; paywalled at JSTOR — cited bibliographically for the rule's origin. Checked 2026-07-29.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- Primary sources
- 6 cited below
- Method
- χ² = Σ (O − E)² ⁄ E df = k − c
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled