Chi-Square Test Statistic Calculator
The chi-square goodness-of-fit test checks whether observed category counts match the counts you would expect under a hypothesis. Enter the observed and expected count for each category, up to four; leave a category at zero expected to skip it. The calculator returns the chi-square statistic and the degrees of freedom.
Chi-square formula
Chi-square = sum over categories of (O - E)^2 / E
Degrees of freedom = (categories used) - 1
(a category is counted only when its expected count is > 0)
O is the observed count and E is the expected count in each category. The degrees of freedom here assume a simple goodness-of-fit test with no parameters estimated from the data; subtract one more for each estimated parameter.
Worked example
For two categories with observed 90 and 110 against expected 100 and 100: the contributions are (90 minus 100) squared divided by 100 = 1.00 and (110 minus 100) squared divided by 100 = 1.00. The chi-square statistic is 2.00 with 2 minus 1 = 1 degree of freedom.
Chi-square statistic: frequently asked questions
What does the chi-square statistic measure?
It measures how far a set of observed counts departs from the counts expected under a hypothesis. Each category contributes the squared difference between observed and expected, divided by the expected. Summing these gives the test statistic; larger values indicate a worse fit.
What is the formula?
Chi-square equals the sum over categories of (observed minus expected) squared, divided by expected. The degrees of freedom for a goodness-of-fit test is the number of categories minus one, minus any parameters estimated from the data.
How do I read the result?
Compare the statistic to a chi-square critical value for your degrees of freedom and chosen significance level, or find its p-value. A statistic above the critical value means you reject the hypothesis that observed matches expected. This tool reports the statistic and degrees of freedom.
What is a common rule for expected counts?
The chi-square approximation is reliable when each expected count is at least 5. With smaller expected counts, consider combining categories or using an exact test. The calculator still computes the statistic but the approximation may be weak.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods: Chi-square goodness-of-fit test.
Reviewed by the CalculatorHub team, edited by James Graham, 19 June 2026. See our methodology.