What the chi-square test asks in genetics
When you cross organisms and count the offspring, the numbers rarely match a Mendelian ratio exactly. Chance alone produces some scatter. The chi-square goodness-of-fit test asks whether the gap between what you observed and what a genetic hypothesis predicts is small enough to blame on chance, or large enough to suggest the hypothesis is wrong.
Use this calculator after a monohybrid, dihybrid or test cross. Enter the count in each phenotype class and the expected ratio, such as 3, 1 or 9, 3, 3, 1. The tool scales the ratio to your total, computes the chi-square statistic, degrees of freedom and p-value, and tells you whether the result is significant at the 5% level. It applies to counts of individuals, not percentages or means.
Formula and variables
χ² = Σ (O − E)² / E
- O is the observed count in a class.
- E is the expected count: total observed × (ratio part ÷ sum of ratio parts).
- df is the number of classes minus 1, here k − 1.
- p is the probability of a chi-square value at least this large if the hypothesised ratio is true.
Common 5% critical values are 3.841 for 1 df, 5.991 for 2 df, 7.815 for 3 df and 9.488 for 4 df. If χ² exceeds the critical value, p is below 0.05 and the hypothesis is rejected.
Worked example
A dihybrid pea cross gives 315 round-yellow, 101 round-green, 108 wrinkled-yellow and 32 wrinkled-green, a total of 556. The hypothesis is 9:3:3:1.
- Expected: 556 × 9/16 = 312.75, 556 × 3/16 = 104.25 (twice), 556 × 1/16 = 34.75.
- Terms: 2.25²/312.75 = 0.0162; 3.25²/104.25 = 0.1013; 3.75²/104.25 = 0.1349; 2.75²/34.75 = 0.2176.
- χ² = 0.4700 with df = 3, and p = 0.9254.
The value is far below 7.815, so the data fit 9:3:3:1 well. A simpler check: 45 and 35 offspring against 1:1 gives expected 40 and 40, χ² = 25/40 + 25/40 = 1.25, df = 1, p = 0.2636, also not significant.
Common mistakes and how to interpret the result
- Entering percentages or proportions. The test needs raw counts; the same percentages from a sample of 20 and 2000 mean very different things.
- Small expected counts. When any expected value is below 5, the chi-square approximation is unreliable. The tool warns you; combine classes or use an exact test.
- Misreading a non-significant result. A high p-value means the data are consistent with the hypothesis, not that it is proven.
- Wrong degrees of freedom. This tool uses k − 1. If you estimated parameters from the same data, for example allele frequencies in a Hardy-Weinberg test, you must subtract one more df per estimated parameter.
Related calculators
- Punnett Square Calculator
- Dihybrid Cross Punnett Square Calculator
- Hardy-Weinberg Calculator
- Chi-Square Calculator