Chi-Square Calculator for Genetic Ratios
Free genetics chi-square calculator — test observed counts against 3:1, 9:3:3:1, 1:2:1 or Hardy-Weinberg. Degrees of freedom derived for you.
Chi-Square Calculator for Genetic Ratios
Background.
This chi-square calculator tests whether the offspring counts from a genetic cross are consistent with the ratio your hypothesis predicts. Choose the expected ratio, enter the observed count for each class, and it returns the chi-square statistic, the degrees of freedom, the p-value, the critical value at your chosen significance level, and a plain-language conclusion.
The reason this is a genetics tool rather than a generic statistics tool is the degrees of freedom. That single number is where most chi-square work in genetics goes wrong, and it is not something you should have to supply. NIST states the rule generally: the statistic follows approximately a chi-square distribution with k − c degrees of freedom, where k is the number of non-empty cells and c is the number of estimated parameters plus one. For a **fixed** Mendelian ratio — 3:1, 9:3:3:1, 1:2:1, 1:1, 1:1:1:1 — nothing is estimated from your data, because the ratio came from the hypothesis. So c = 1 and df = k − 1: a dihybrid F2 with four classes has 3 degrees of freedom. For a **Hardy-Weinberg** test the situation is different: the allele frequency p is estimated from the very counts being tested, so c = 2 and df = k − 2 = 1, not 2. Using 2 degrees of freedom there raises the critical value from 3.841 to 5.991 and makes the test far too permissive — you would fail to detect real departures. NCBI's own dbSNP documentation records this exact argument, that because only one independent parameter is estimated there should only be one degree of freedom. This calculator derives df from the hypothesis you pick, so it cannot be entered wrongly.
The worked example built into the page is Mendel's own dihybrid data, from the annotated translation published in Genetics in 2016: 556 seeds giving 315 round-and-yellow, 108 round-and-green, 101 angular-and-yellow and 32 angular-and-green. Against a 9:3:3:1 expectation those become expected counts of 312.75, 104.25, 104.25 and 34.75, and the statistic comes to 0.4700 on 3 degrees of freedom — far below the critical value of 7.815, with a p-value of 0.9254. The data are consistent with 9:3:3:1.
**Three limits belong beside the answer rather than below it.** First, a chi-square test can only ever fail to reject a hypothesis; it never proves one, and the verdict wording on this page is careful about that. Second, the test is an asymptotic approximation to a discrete distribution, so it degrades when expected counts are small — this page reports the smallest expected count so you can judge it, and cautions below 5, though some sources set that bar at 10. Third, for Hardy-Weinberg specifically, Wigginton, Cutler and Abecasis showed that the chi-square test can have inflated type I error rates even in samples of a thousand individuals when the minor allele is uncommon, and recommended an exact test instead; NCBI's documentation records their own intention to switch to Fisher's exact test for the same reason.
If you already have a chi-square statistic and its degrees of freedom and only need the tail probability, the general p-value calculator covers z, t, chi-square and F distributions and is the better tool. This page exists for the other half of the job: turning counts and a genetic hypothesis into a statistic in the first place.
What is chi-square calculator for genetic ratios?
A chi-square goodness-of-fit test asks whether a set of observed counts is far enough from what a hypothesis predicts to be worth taking seriously. NIST gives the statistic as χ² = Σ(Oᵢ − Eᵢ)²/Eᵢ, summed over the classes: for each class, take the difference between what you observed and what the hypothesis expected, square it so that shortfalls and excesses both count, and divide by the expected value so that a deviation of 10 in a class expecting 20 weighs far more than the same deviation in a class expecting 2,000. The sum is a single dimensionless number that grows as the fit worsens. In genetics the expected counts come from a segregation ratio. A monohybrid F2 cross predicts 3:1 in phenotypes and 1:2:1 in genotypes; a dihybrid F2 predicts 9:3:3:1; a testcross predicts 1:1 for one locus and 1:1:1:1 for two unlinked loci. Multiply each ratio share by the total number of offspring and you have the expected counts. A Hardy-Weinberg test works differently: the expected counts are p²N, 2pqN and q²N, and p is not given by the hypothesis but estimated from the observed genotypes by gene counting, p = (2·n(AA) + n(Aa)) ÷ 2N. That estimation is what costs the extra degree of freedom. The result is then compared with a critical value: NIST's rule is to reject the null when χ² exceeds χ²₁₋α,k₋c. Equivalently, reject when the p-value falls below alpha. Both are shown here, and they always agree. What the test cannot do is confirm anything. Failing to reject 9:3:3:1 means the data are consistent with it — but they may equally be consistent with several other ratios, especially in a small sample, and a test with low power fails to reject almost everything.
How to use this calculator.
- Pick the expected ratio your hypothesis predicts. This also sets the degrees of freedom, so there is nothing else to look up.
- Enter the observed counts in ratio order. For 9:3:3:1 that is the double-dominant class first, then the two single-dominant classes, then the double-recessive. For Hardy-Weinberg, enter AA, then Aa, then aa.
- Leave the unused count fields alone. A two-class ratio reads only the first two boxes, so whatever is left in boxes three and four is ignored and cannot affect the result.
- Choose alpha before looking at the data, not after. Moving from 0.05 to 0.10 because the result was close is the classic way to manufacture a significant finding.
- Read the conclusion, then check the smallest expected count. If it is below about 5 the chi-square approximation is shaky and the caution in the verdict is telling you to treat the p-value as rough.
- For a Hardy-Weinberg test on genotyping data, treat a significant result as a quality-control flag first and a biological finding second. Departure at a single marker most often means allele dropout or a failing probe, not selection or inbreeding.
The formula.
Start by converting the ratio into expected counts. Add the ratio's parts — 9 + 3 + 3 + 1 = 16 for a dihybrid F2 — and give each class its share of the total. With Mendel's 556 seeds that gives 556 × 9/16 = 312.75, then 104.25, 104.25 and 34.75. Note that expected counts are not rounded to whole numbers; rounding them first is a common error that changes the statistic.
Then accumulate the statistic. For each class, subtract expected from observed, square the difference, and divide by the expected count. For Mendel's data: (315 − 312.75)² ÷ 312.75 = 0.0161870504; (108 − 104.25)² ÷ 104.25 = 0.1348920863; (101 − 104.25)² ÷ 104.25 = 0.1013189448; (32 − 34.75)² ÷ 34.75 = 0.2176258993. The sum is χ² = 0.4700239808. Squaring is what makes the test two-sided in effect while using only the upper tail of the distribution: too many double-dominants and too few both push the statistic up.
DEGREES OF FREEDOM is the step that carries the genetics. NIST's rule is df = k − c with c equal to the number of estimated parameters plus one. The plus one is the constraint that the expected counts must sum to the observed total — fix any k − 1 of them and the last is determined. For a fixed Mendelian ratio nothing else is estimated, so df = k − 1: three for a four-class dihybrid, one for a two-class 3:1, two for a three-class 1:2:1. For a Hardy-Weinberg test the allele frequency p is computed from the same counts being tested, which uses up a second degree of freedom, so a three-genotype test has df = 3 − 2 = 1. This matters a great deal: the critical value at alpha 0.05 is 3.841 for one degree of freedom but 5.991 for two, so using 2 df would let a genuinely departing population pass. NCBI's dbSNP FAQ records a contributor making exactly this argument — that because only one independent parameter is being estimated there should only be one degree of freedom — and notes the point was contested in their own published tables.
The decision follows NIST directly: reject the null when χ² > χ²₁₋α,df. For Mendel's data, 0.4700 does not exceed 7.815, so the hypothesis stands. The p-value, 0.9254, says the same thing from the other side: a fit this poor or worse would arise by chance about 93 % of the time if 9:3:3:1 were true. Note the wording used throughout: 'fail to reject', never 'confirm'. A chi-square test has no mechanism for proving a hypothesis, and a small sample fails to reject almost anything.
ROUNDING STAGE — FINAL ONLY. The expected counts, the squared deviations, the incomplete-gamma series behind the p-value and the bisection behind the critical value all run in arbitrary-precision decimal arithmetic on a 34-digit working precision, and each returned number is rounded exactly once, to ten decimal places, on return. Nothing is looked up: the critical value is found by inverting the same tail function that produces the p-value, and the test suite asserts it reproduces all nine entries of NIST's published table for 1 to 3 degrees of freedom at alpha 0.10, 0.05 and 0.01. If the distribution code were wrong, those nine assertions would fail.
WHAT IS REFUSED. Negative or fractional counts, and a total of zero, are data-entry errors. A monomorphic sample in Hardy-Weinberg mode is refused rather than answered: with only one allele present, two of the three expected counts are zero and the statistic would contain 0 ÷ 0. There is no Hardy-Weinberg departure to test when there is nothing to be heterozygous with.
A worked example.
Mendel's dihybrid experiment on seed shape and colour produced, in his own words as rendered by Abbott and Fairbanks's 2016 translation, '556 seeds… of these there were 315 round and yellow, 101 angular and yellow, 108 round and green, and 32 angular and green'. Do these counts fit the 9:3:3:1 ratio that independent assortment of two dominant traits predicts? The ratio's parts sum to 16, so the expected counts are 556 × 9/16 = 312.75 for round-and-yellow, 556 × 3/16 = 104.25 for each of the two single-dominant classes, and 556 × 1/16 = 34.75 for angular-and-green. Note that the two middle classes have the same expectation, which is why the order in which you enter them makes no difference — the translation lists angular-yellow before round-green, most textbooks do the reverse, and the statistic is identical either way. Accumulating: (315 − 312.75)² ÷ 312.75 = 0.0162, (108 − 104.25)² ÷ 104.25 = 0.1349, (101 − 104.25)² ÷ 104.25 = 0.1013, and (32 − 34.75)² ÷ 34.75 = 0.2176. The chi-square statistic is 0.4700239808. With four classes and nothing estimated from the data, the degrees of freedom are 4 − 1 = 3, and the critical value at alpha 0.05 is 7.815 — a figure this calculator computes rather than looks up, and which matches NIST's published table. Since 0.4700 is nowhere near 7.815, the conclusion is to fail to reject: the data are consistent with a 9:3:3:1 ratio. The p-value of 0.9254 says the same thing — a fit this poor or worse would happen about 93 % of the time by chance alone if the hypothesis were true. The smallest expected count is 34.75, comfortably above any version of the minimum-expected-count rule, so no caution applies and the approximation is sound here. One last note on interpretation, and it cuts both ways. Failing to reject is not proof. A p-value of 0.93 is a remarkably good fit — so good that R. A. Fisher famously argued Mendel's results across all his experiments were collectively closer to expectation than chance should allow, a debate that has run for a century. But taken on its own, this single test establishes only that the data give no reason to abandon 9:3:3:1. It does not rule out other ratios the sample is too small to distinguish, and it says nothing at all about whether some seeds failed to germinate before being scored.
Frequently asked questions.
How many degrees of freedom does a genetics chi-square test have?
Why does a Hardy-Weinberg chi-square test use 1 degree of freedom and not 2?
How is this different from a general p-value calculator?
What does it mean if my chi-square test rejects the expected ratio?
What is the minimum sample size or expected count for a chi-square test?
Can a chi-square test prove that my cross follows a 9:3:3:1 ratio?
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 oracle for this page's arithmetic: no critical value is hard-coded here, and the test suite asserts 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.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 682 calculators remain free
- No billing is enabled