Chi-Square Genetics Calculator
Test whether observed offspring counts fit an expected Mendelian ratio such as 3:1, 1:2:1 or 9:3:3:1, with the chi-square statistic, degrees of freedom and p-value.
The question the test answers
Real crosses never give perfect ratios. If a cross expected to give 3 : 1 produces 82 and 18 offspring, is that close enough? The chi-square goodness-of-fit test measures how far observed counts are from the expected counts and asks how often chance alone would produce a difference that large. The statistic is χ² = Σ (observed − expected)² ÷ expected, summed over the classes. The degrees of freedom are the number of classes minus one. The p-value is the probability of a χ² at least that large if the expected ratio is correct.
Mendel’s peas
Mendel’s dihybrid cross of round yellow and wrinkled green peas produced 315 round yellow, 108 round green, 101 wrinkled yellow and 32 wrinkled green seeds, 556 in all. For a 9 : 3 : 3 : 1 ratio the expected counts are 312.75, 104.25, 104.25 and 34.75. The contributions to χ² are 0.016, 0.135, 0.101 and 0.218, a total of 0.470 with 3 degrees of freedom. The p-value is 0.925: a fit this good or better happens by chance only about 7.5% of the time. For his monohybrid seed-shape cross, 5,474 round and 1,850 wrinkled, χ² is 0.263 against 3 : 1, p = 0.608. The statistician R. A. Fisher noted in 1936 that Mendel’s results were collectively closer to expectation than chance would usually allow, a debate that continues; the arithmetic is a good reminder that too good a fit is also informative.
Reading the p-value
By convention, p below 0.05 is called significant: the deviation is unlikely to be chance alone, and the hypothesised ratio is rejected. For 1 degree of freedom the critical value is 3.84, for 2 it is 5.99 and for 3 it is 7.81. A common misconception is that p above 0.05 proves the ratio is correct. It does not; it only means the data do not contradict it, and a small sample may fail to detect a real difference. Another mistake is to run the test on percentages instead of counts: χ² depends on sample size, and 82% versus 75% means something very different for 100 offspring than for 10,000.
When the test is unreliable
The chi-square distribution is an approximation that works when every expected count is at least about 5. With smaller expected counts, combine classes or use an exact test. The classes must be mutually exclusive and counted, not measured, and each offspring must be independent. If allele frequencies or other parameters are estimated from the same data, as in a Hardy-Weinberg test, subtract an extra degree of freedom for each.
How to use it
- Enter the observed counts for each phenotype class, separated by commas.
- Enter the expected ratio with one term per class, such as 9:3:3:1.
- Read the expected counts, each class’s contribution, χ², the degrees of freedom and the p-value.
- Check that every expected count is at least 5 before trusting the result.
Questions from the teaching lab
How do you do a chi-square test for a 9:3:3:1 ratio?
Multiply the total by 9/16, 3/16, 3/16 and 1/16 for the expected counts, then add (observed − expected)² ÷ expected for each class. Mendel’s 315, 108, 101 and 32 give χ² = 0.470 with 3 degrees of freedom and p = 0.925, a good fit.
What is the critical value for chi-square with 1 degree of freedom?
3.841 at the 5% significance level. For 2 degrees of freedom it is 5.991 and for 3 it is 7.815. A χ² value above the critical value means the deviation from the expected ratio is significant at that level.
How many degrees of freedom does a genetics chi-square test have?
The number of phenotype classes minus one when the expected ratio comes from theory: 1 for a 3:1 test, 2 for 1:2:1 and 3 for 9:3:3:1. Subtract one more for each parameter estimated from the data.
Does a p-value above 0.05 prove my ratio is right?
No. It means the observed counts are consistent with the ratio, not that the ratio is proven. Small samples can fail to reveal real differences, and other ratios may fit the data equally well.
Disclaimer: Genetics results apply textbook models, Mendelian ratios, Hardy-Weinberg equilibrium and simple Tm formulas, to the values you enter. They are for education and are not medical advice, genetic counselling or parentage testing. Real inheritance involves linkage, variants and family history these models leave out: anyone concerned about a condition, a pregnancy or a test result should speak to a doctor or genetic counsellor.