About the Chi-Square Calculator
This chi-square calculator runs the two most common χ² tests. The goodness-of-fit test checks whether observed counts across categories match an expected distribution — for example whether a die is fair or whether customer visits are spread evenly across weekdays. The test of independence checks whether two categorical variables in a contingency table are related, such as gender and product preference.
Enter your counts, choose a significance level and it returns the chi-square statistic, degrees of freedom, the p-value, the critical value and a plain-English decision. The table breaks the statistic down by cell, so you can see which categories contribute most to any difference.
Use raw counts, not percentages, for the observed data. Expected values in the goodness-of-fit test can be counts, percentages or ratios — they are rescaled to the observed total — and leaving them blank tests for equal proportions. The test is reliable when every expected count is at least 5.
With the default inputs, the chi-square statistic (χ²) is 5.1. Change any value above to recalculate instantly.
How to use the chi-square calculator
- 1Choose goodness of fit (one list of counts) or test of independence (a table).
- 2Enter observed counts — one list, or one table row per line.
- 3For goodness of fit, optionally enter expected counts or proportions.
- 4Pick a significance level, usually 0.05.
- 5Compare the p-value with α and read the decision and cell contributions.
Formula and method
For every cell the calculator squares the gap between the observed count O and the expected count E, divides by E, and adds the results. In a goodness-of-fit test E is the total multiplied by each category’s expected proportion. In a test of independence E = (row total × column total) ÷ grand total, which is what you would expect if the two variables were unrelated.
The p-value is the right-tail probability of the chi-square distribution with the given degrees of freedom, computed from the regularized incomplete gamma function. If the p-value is below α (equivalently χ² exceeds the critical value), you reject the null hypothesis. The approximation assumes independent observations and expected counts of about 5 or more.
- O
- Observed count in a cell
- E
- Expected count in that cell under the null hypothesis
- k
- Number of categories (goodness of fit)
- r, c
- Number of rows and columns in the contingency table
Worked examples
Is a die fair? 120 rolls
With a fair die each face is expected 20 times. Σ(O − E)²/E = (4 + 9 + 0 + 36 + 4 + 49) ÷ 20 = 5.1 with 5 degrees of freedom, giving p ≈ 0.40, so there is no evidence the die is unfair.
Goodness of fit with expected percentages
The expected shares 40/40/20% of 100 give 40, 40 and 20. χ² = 100/40 + 100/40 + 0 = 5 with 2 degrees of freedom, p ≈ 0.082 — not significant at 0.05, but it would be at 0.10.
2×2 test of independence
Every expected count is 50 × 50 ÷ 100 = 25, and each cell is 5 away, so χ² = 4 × 25/25 = 4 with 1 degree of freedom. p ≈ 0.0455 is below 0.05, so the variables appear related (this is Pearson’s χ² without Yates’ correction).
2×3 contingency table
Column totals are 30, 40 and 50 out of 120, so expected counts are 15, 20, 25 in each row. The cells contribute 1.667 + 0 + 1 twice, for χ² ≈ 5.33 with (2 − 1)(3 − 1) = 2 degrees of freedom and p ≈ 0.069.
Frequently asked questions
What does the chi-square test tell you?+
It tells you whether the differences between observed and expected counts are larger than you would expect from random chance alone. A small p-value (below α) means the data do not fit the expected distribution, or that two categorical variables are associated.
How do you calculate degrees of freedom for chi-square?+
For a goodness-of-fit test, df = number of categories − 1. For a test of independence on a table with r rows and c columns, df = (r − 1) × (c − 1). A 2×2 table therefore has 1 degree of freedom.
What is the critical value of chi-square at 0.05?+
It depends on the degrees of freedom: 3.841 for df = 1, 5.991 for df = 2, 7.815 for df = 3, 9.488 for df = 4 and 11.070 for df = 5. If your χ² statistic is larger, the result is significant at the 5% level.
Can I use percentages in a chi-square test?+
Observed values must be actual counts, because the test depends on sample size. Expected values in a goodness-of-fit test can be percentages or ratios; the calculator rescales them to your observed total.
What if expected counts are less than 5?+
The chi-square approximation becomes unreliable when expected counts are small. Combine sparse categories, collect more data, or use Fisher’s exact test for small 2×2 tables.
Does this use Yates’ continuity correction?+
No. It reports Pearson’s chi-square without the Yates correction, which is the standard statistic in most textbooks and software. The Yates version is more conservative and gives a slightly larger p-value for 2×2 tables.