Math
Chi-Square Calculator
Run a chi-square test for independence on a contingency table or a goodness-of-fit test on observed vs. expected counts. Returns the statistic, p-value, critical values, and a significance verdict.
Chi-square test
Chi-square statistic
4.5
df = 1 ยท p-value = 0.0339
Critical (a = 0.05)
3.8415
Critical (a = 0.01)
6.6349
Significant at the 0.05 level. Reject the null hypothesis.
Expected counts under independence
| 25 | 25 |
| 20 | 20 |
Frequently Asked Questions about the Chi-Square Calculator
What is the difference between the independence test and goodness-of-fit?
The independence test checks whether two categorical variables are related (for example, whether gender and product preference are linked in a survey). Goodness-of-fit checks whether a single set of observed counts matches a target distribution (for example, whether a die rolled 600 times produces roughly 100 of each face). Both tests use the same formula, sum of (O - E)^2 / E, but they derive the expected counts differently.
How are expected values calculated for independence?
For each cell, the expected count is (row total x column total) / grand total. This is the count you would see if the two variables were completely unrelated. The calculator displays the full expected table next to your observed counts so you can spot where the largest gaps are.
What does the p-value mean?
The p-value is the probability of getting a chi-square statistic as large as yours, or larger, if the null hypothesis were true. A p-value below 0.05 means the result is statistically significant at the 5% level, so you reject the null and conclude the variables are associated (independence test) or the distribution does not fit (goodness-of-fit). Results are estimates based on asymptotic theory and assume an adequate sample size, so a common rule of thumb is that each expected count should be at least 5.
How do I read the critical values at 0.05 and 0.01?
If your chi-square statistic is greater than or equal to the critical value at alpha 0.05, the result is significant at the 5% level. The 0.01 critical value is a stricter threshold, so crossing it means significance at 1%. Both critical values depend only on the degrees of freedom, and the calculator flags each threshold automatically so you do not need a table.
How are degrees of freedom calculated?
For the independence test, df = (rows - 1) x (columns - 1), so a 2x2 table gives df = 1 and a 3x4 table gives df = 6. For goodness-of-fit, df = number of categories - 1. If you estimated parameters from the data before running the test (for example, fitting a mean and standard deviation), subtract one more degree of freedom per estimated parameter, since the calculator does not do this automatically.