ChiTest
Chi-Square Calculator
χ² = Σ((observed − expected)² / expected).
Chi-square statistic for goodness of fit
Chi-square sums the squared difference between observed and expected counts, divided by the expected count, across every category.
| Observed | Expected | Chi-square | Degrees of freedom |
|---|---|---|---|
| 45, 55 | 50, 50 | 1.000 | 1 |
| 20, 30, 50 | 25, 25, 50 | 2.000 | 2 |
| 10, 20, 30, 40 | 25, 25, 25, 25 | 20.000 | 3 |
Degrees of freedom is the number of categories minus 1. Compare the statistic against the critical value for that df: at 0.05 significance the thresholds are 3.84 for 1 df, 5.99 for 2 and 7.81 for 3. On that basis the first two rows are consistent with the expected distribution and the third, at 20.000 against a threshold of 7.81, is clearly not. Chi-square needs reasonably large expected counts in every category - the usual guidance is at least 5 - and it works on raw counts, never on percentages or proportions.
Measuring how 'surprised' the data is
Chi-square sums up, category by category, how far your actual observed counts deviate from what you'd expect if there were no real effect — the bigger the number, the less likely the difference is due to random chance alone.
Where it's used
A/B testing, survey analysis, and checking whether a die or coin is fair all use chi-square to test whether an observed pattern could plausibly be random noise.
Frequently asked questions
I rolled a die 60 times and got: 8, 12, 9, 11, 10, 10 for faces 1–6. Is the die fair?
Expected: 10 each. χ² = (8−10)²/10 + (12−10)²/10 + … = 0.4+0.4+0.1+0.1+0+0 = 1.0. With 5 degrees of freedom, the critical value at p=0.05 is 11.07. Since 1.0 < 11.07, there's no evidence the die is unfair — the variation is normal randomness.
How is chi-square different from a t-test?
Chi-square tests categorical/count data (did more people choose A vs B?). T-tests compare numerical means (is group A's average score higher than group B's?). Use chi-square for frequencies and proportions; use t-tests for measurements and averages.
What are degrees of freedom in a chi-square test?
df = (number of categories − 1) for a goodness-of-fit test. For a contingency table: df = (rows − 1) × (columns − 1). More degrees of freedom shift the critical value higher, meaning you need a larger χ² to reach significance.
My website A/B test shows 45/500 vs 55/500 conversions. Is this significant?
Expected: 50 each. χ² = (45−50)²/50 + (55−50)²/50 + (455−450)²/450 + (445−450)²/450 = 0.5+0.5+0.056+0.056 = 1.11. With df=1, critical value at p=0.05 is 3.84. Since 1.11 < 3.84, the difference is NOT statistically significant — you need more data.
Related Math calculators
Bayes' Theorem Calculator
Posterior probability P(A|B) via Bayes' theorem.
OpenVariance Calculator
Sample and population variance from a dataset.
OpenPermutation & Combination Calculator
nPr permutations and nCr combinations.
OpenProbability Calculator
Basic probability, complement, and joint probability.
OpenLast updated: September 6, 2026