Stuck on expected counts or unsure which chi-square test to use?
This chi square test calculator helps you handle the two most common classroom cases: goodness of fit and test of independence. It shows the setup, expected counts, test statistic, degrees of freedom, p-value, assumptions, and a plain-language interpretation. That means you can check both the math and the meaning before you submit homework or write your results section.
Inputs and Options
Results
Data Entry
What this means
Show step-by-step solution / formulas
Chi-square test of independence
Expected count for a cell: Eij = (row total × column total) / grand total
Test statistic: χ2 = Σ (Oij - Eij)2 / Eij
Degrees of freedom: (r - 1)(c - 1)
Effect size: Cramer's V = √(χ2 / (N × min(r - 1, c - 1)))
Chi-square goodness-of-fit test
Expected count for a category: Ei = n pi or the expected count you provide.
Test statistic: χ2 = Σ (Oi - Ei)2 / Ei
Degrees of freedom: k - 1 when expected values are fixed in advance.
After you calculate, this section will also show the step-by-step solution for your data.
Common mistakes
- Entering percentages or proportions instead of counts.
- Using the test when observations are not independent.
- Ignoring very small expected counts.
- Mixing row labels or category labels with the numeric cells.
Next, visit the Hypothesis Tests hub or use the P-Value Calculator if you want to compare your chi-square result with other test outputs.

What this calculator does
This calculator helps you run a chi-square goodness-of-fit test or a chi-square test of independence. In both cases, it compares observed counts to expected counts using the chi-square formula . It then reports the test statistic, degrees of freedom, p-value, and a short interpretation.
For a goodness-of-fit test, the calculator checks whether one categorical variable follows an expected distribution. For a test of independence, it checks whether two categorical variables are related by using a contingency table and expected counts computed from row totals, column totals, and the grand total.
When to use it (and when not to)
Use this calculator when your data are counts in categories. Good examples are favorite drink by group, pass/fail by study method, or survey responses by gender. Use goodness of fit when you have one categorical variable and want to compare observed counts to a claimed pattern. Use test of independence when you have two categorical variables and want to know whether they are associated.
Do not use this calculator for means, standard deviations, raw measurement scores, correlation, or regression. Do not use it when your table entries are percentages instead of counts. Also be careful when expected counts are too small, because the chi-square approximation may not be reliable. Many intro statistics sources use the rule that expected counts should be at least 5, especially in basic classroom settings.

How it works
The calculator starts with your observed counts. Then it finds the expected counts under the null hypothesis. For a goodness-of-fit test, the expected count is usually , where is the total sample size and pi is the expected proportion for a category. For a test of independence, each expected cell count is found with
After that, it adds up all values to get .
Next, it finds the degrees of freedom. For goodness of fit, the degrees of freedom are usually the number of categories minus 1 in basic intro-stat settings. For independence, the degrees of freedom are , where is the number of rows and is the number of columns. The calculator then uses the chi-square distribution to get the p-value and help you decide whether to reject the null hypothesis.

Step-by-step example
Suppose a teacher wants to know whether study method and exam result are related. The class data are:
- Flashcards: 36 pass, 14 fail
- Practice tests: 24 pass, 26 fail
This is a chi-square test of independence because there are two categorical variables: study method and exam result.
Step 1: State the hypotheses
- H₀: Study method and exam result are independent.
- H₁: Study method and exam result are related.
Step 2: Find the totals
- Row totals: 50 and 50
- Column totals: 60 pass and 40 fail
- Grand total: 100
Step 3: Find the expected counts
Use
- Flashcards, Pass:
- Flashcards, Fail:
- Practice tests, Pass:
- Practice tests, Fail:
Step 4: Compute the chi-square statistic
Step 5: Find the degrees of freedom
Step 6: Make the decision
With and , the p-value is about 0.014. If , then , so reject H₀.
Step 7: Interpret the result
There is evidence that study method and exam result are related in this sample. In simple words, the pass/fail pattern looks different across the two study methods.

Common mistakes
- Using percentages instead of counts
- Choosing independence when the problem is really goodness of fit
- Forgetting to compute or check expected counts
- Using the wrong degrees of freedom
- Saying “the variables cause each other” when the test only shows association, not causation
- Ignoring small expected counts and still trusting the result without caution

FAQs: Chi Square Test Calculator
What does this result mean?
A small p-value means your observed counts are far enough from the expected counts that the null hypothesis is not a good fit for the data. In class language, that usually means you reject H₀. For independence, it suggests the variables are related. For goodness of fit, it suggests the observed distribution does not match the claimed distribution.
Which test should I use?
Expected counts are the values you would expect if the null hypothesis were true. In a test of independence, each expected cell count is
In a goodness-of-fit test, expected counts often come from .
Why is my answer different from my teacher’s?
Common reasons include a different rounding rule, a different expected distribution, a continuity correction choice in another software package, or a teacher using a table-based critical-value method instead of a p-value method. Sometimes the difference comes from entering percentages instead of counts.
What assumptions does the chi-square test need?
Your data should be counts, categories should be mutually exclusive, observations should be independent, and expected counts should be large enough for the chi-square approximation to work well.
Can I use this test for percentages or means?
No. Chi-square tests are for categorical count data. If you have means, proportions from summary data, or continuous measurements, use a different test.
Does a significant chi-square result prove causation?
No. A significant chi-square result can show that variables are associated or that the distribution differs from what was expected, but it does not prove cause and effect by itself.
What if some expected counts are too small?
Be careful. Very small expected counts can make the chi-square approximation weak. In simple classroom settings, this is often a sign to reconsider the setup, combine categories if justified, or use a different method such as Fisher’s exact test for a small 2×2 table.
Related BrainMattersLearning statistics tools
Link up to:
- Statistics Calculators pillar
- Hypothesis Tests hub
Related statistical tests:
- One-Proportion Z Test Calculator
- Two-Proportion Z Test Calculator
- Two-Sample T-Test Calculator
- Paired T-Test Calculator
- Critical Value Calculator
References
Illowsky, B., & Dean, S. (2023). Introductory statistics 2e: 11.2 Goodness-of-fit test. OpenStax. https://openstax.org/books/introductory-statistics-2e/pages/11-2-goodness-of-fit-test
Illowsky, B., & Dean, S. (2023). Introductory statistics 2e: 11.3 Test of independence. OpenStax. https://openstax.org/books/introductory-statistics-2e/pages/11-3-test-of-independence
JMP Statistical Discovery LLC. (n.d.). The chi-square test. JMP Statistical Knowledge Portal. https://www.jmp.com/en/statistics-knowledge-portal/linear-models/chi-square-test
Penn State Eberly College of Science. (n.d.). 11: Chi-square tests. STAT 200. https://online.stat.psu.edu/stat200/lesson/11