Chi-Square Goodness of Fit Calculator (Genetics)
Enter observed offspring counts and an expected ratio to compute χ² = Σ(O−E)²/E, testing whether your data statistically matches the predicted Mendelian ratio. Two 3D diagrams compare a close-fitting and a poor-fitting dataset, and charts show observed versus expected counts.
Reviewed by the ToolNestr Editorial Team — July 2026
Enter observed counts and the expected ratio for up to 4 categories.
Good fit vs poor fit
1. Close fit (low χ²)
Observed (amber) and expected (indigo) bars are nearly the same height — small, random deviation.
2. Poor fit (high χ²)
Observed (amber) bars diverge noticeably from expected (indigo) — a systematic deviation, not just chance.
Chi-square graphs
How it works
The core idea in one line: chi-square measures how surprised you should be by your data, given a hypothesized ratio — small, random deviations from the prediction produce a small χ², while large, systematic deviations produce a large one that signals something besides chance is going on.
χ² = Σ(O − E)² / E
O = observed count, E = expected count, summed across all categories
df = categories − 1
degrees of freedom for the test
critical value (df=3, p=0.05) = 7.815
a common threshold for a 4-category test — exceeding it suggests a significant deviation
For each phenotype category, squaring the difference between observed and expected counts removes the sign (so both over- and under-counts count as deviations), and dividing by the expected count scales that squared deviation relative to how large a difference would actually be meaningful for that category's size. Summing this scaled squared-deviation across every category produces χ², which can then be compared against a critical value (from the chi-square distribution, based on degrees of freedom) to judge whether the observed deviation is small enough to attribute to chance, or large enough to reject the hypothesized ratio.
Worked example 1 — Mendel's classic dihybrid pea data
Given: Observed: 315 round-yellow, 101 round-green, 108 wrinkled-yellow, 32 wrinkled-green (total 556). Expected ratio: 9:3:3:1.
This is Mendel's own historical dihybrid data — the very low χ² (0.470, far below the 7.815 threshold) shows a remarkably close fit to the predicted ratio.
Worked example 2 — a monohybrid cross with a poor fit
Given: Observed: 60 dominant, 40 recessive (total 100). Expected ratio: 3:1 (should be 75:25).
Since χ²=12.0 far exceeds the critical value of 3.841, this data significantly deviates from a 3:1 ratio — something other than simple Mendelian inheritance may be occurring.
Common chi-square critical values (p = 0.05)
Compare your calculated χ² against the value matching your degrees of freedom to judge statistical significance.
| Categories | df | Critical value (p=0.05) |
|---|---|---|
| 2 (monohybrid, 3:1) | 1 | 3.841 |
| 3 (1:2:1) | 2 | 5.991 |
| 4 (dihybrid, 9:3:3:1) ★ | 3 | 7.815 |
| 5 | 4 | 9.488 |
★ Reference row (worked example 1). A χ² below the critical value means the data is consistent with (fails to reject) the expected ratio.
Where chi-square goodness of fit actually matters
🌱 Verifying Mendelian inheritance patterns
Geneticists use chi-square tests to statistically confirm whether observed offspring ratios genuinely match predicted Mendelian patterns, rather than relying on a "close enough by eye" judgment.
🔬 Detecting gene linkage
When a dihybrid cross's observed ratio significantly deviates from the expected 9:3:3:1 (a high χ²), it often signals that the two genes are linked rather than assorting independently.
🧬 Evaluating breeding experiment results
Agricultural and animal breeding researchers use chi-square tests to confirm whether a cross behaved as predicted before drawing conclusions about a trait's inheritance pattern.
📊 General statistical hypothesis testing
The chi-square goodness of fit test extends far beyond genetics — it is a general statistical tool for comparing any observed categorical data against a theoretical expected distribution.
Common misconceptions
"A high chi-square value proves the cross was done incorrectly."
A high χ² only indicates the observed data significantly deviates from the hypothesized ratio — this could mean experimental error, but it could equally mean the underlying genetics doesn't follow the assumed simple pattern (e.g. linked genes, or an incorrect number of genes assumed).
"A chi-square value of exactly 0 is the best possible, most trustworthy result."
A chi-square of exactly 0 (a perfect match) is actually somewhat suspicious in a real biological experiment — real data almost always shows some random variation. Historically, some have questioned whether Mendel's remarkably low chi-square values reflect selective reporting, though this remains debated.
"You can use chi-square to test any sample size, even very small ones."
Chi-square tests assume reasonably large expected counts in each category (typically at least 5) — with very small sample sizes, the test becomes unreliable and other statistical methods (like Fisher's exact test) are more appropriate.
"Failing to reject the expected ratio proves the ratio is definitely correct."
A chi-square test that fails to find a significant difference only means the data is consistent with the expected ratio — it does not prove the ratio is true, since a small sample size could fail to detect a real deviation that actually exists.
Formula sources & further reading
The formulas here are standard, traceable to:
- • OpenStax, Biology 2e — Chapter 12, "Mendel's Experiments and Heredity" (free, peer-reviewed). openstax.org
- • Klug, Cummings & Spencer, Concepts of Genetics — Chapter 3, Chi-Square Analysis.
- • Campbell & Reece, Biology — Chapter 14, Mendel and the Gene Idea.
χ² = Σ(O−E)²/E, df = categories−1. Critical values are standard chi-square distribution table values (p=0.05). Results are rounded for display.
How to use this calculator
Enter observed counts
Type the actual count for each phenotype category (2-4 categories supported).
Enter the expected ratio
Provide the predicted ratio for the same categories, e.g. 3:1 or 9:3:3:1.
Read the fit verdict
χ², degrees of freedom, and a plain-language interpretation solve instantly.
Related tools
Frequently asked questions
What is a chi-square goodness of fit test in genetics?
It is a statistical test that compares observed offspring counts from an actual genetic cross to the counts expected under a hypothesized ratio (like 3:1 or 9:3:3:1), quantifying how well the data fits the Mendelian prediction.
How do you calculate chi-square?
χ² = Σ(O−E)²/E, where O is the observed count and E is the expected count for each phenotype category, summed across all categories.
What does a low chi-square value mean?
A low χ² value means the observed data closely matches the expected ratio — the deviations are small relative to what's expected. Famously, Mendel's own pea data produced unusually low chi-square values, fitting his predicted ratios almost too perfectly.
How do you decide if a chi-square result is significant?
Compare your calculated χ² to a critical value from a chi-square distribution table, using degrees of freedom (categories−1) and a significance level (typically 0.05). If your χ² exceeds the critical value, the observed data significantly deviates from the expected ratio.
What are degrees of freedom in this test?
Degrees of freedom equal the number of phenotype categories minus 1. A monohybrid cross (2 categories) has 1 degree of freedom; a dihybrid cross (4 categories) has 3.