Chi Square Test Calculator: 7 Smart Ways to Check Categorical Data Fast

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.

Chi Square Test Calculator
Use this calculator for a chi-square test of independence or a chi-square goodness-of-fit test. Enter or paste count data, then click Calculate to get the test statistic, degrees of freedom, p-value, expected counts, assumption checks, a step-by-step solution, and a plain-language interpretation.
This page is the main chi-square test page. If you later want a separate helper just for contingency-table setup, that can be added as a supporting tool without replacing this test page.

Inputs and Options

Independence table setup
Use counts only. Do not enter percentages, proportions, means, or standard deviations.
Goodness-of-fit setup
Use observed counts for each category. If you choose expected proportions, they should add up to 1.00.
Outputs to display

Results

Enter values, then click Calculate.

Data Entry

Contingency table setup
Enter observed counts only. Row totals, column totals, and the grand total update automatically from your table.
Paste a contingency table setup
Paste counts from Excel or Google Sheets. You may include row labels and column labels. Use counts only.
Goodness-of-fit data setup
Enter one category per row. Use observed counts only. Expected values follow the expected value mode you selected above.
Paste goodness-of-fit data
Paste one category per line. Use either Label, Observed, Label, Observed, Expected Count, or Label, Observed, Expected Proportion, depending on the expected value mode you selected.

What this means

Your plain-language interpretation will appear here after you calculate.
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 χ2=(OE)2E\chi^2=\sum \frac{(O-E)^2}{E}​. 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 E=npiE=np_i, where nn is the total sample size and pip_ipi​ is the expected proportion for a category. For a test of independence, each expected cell count is found withE=(row total)(column total)grand totalE=\frac{(\text{row total})(\text{column total})}{\text{grand total}}

After that, it adds up all (OE)2E\frac{(O-E)^2}{E} values to get χ2\chi^2.

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 (r1)(c1)(r-1)(c-1), where rr is the number of rows and cc 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

UseE=(row total)(column total)grand totalE=\frac{(\text{row total})(\text{column total})}{\text{grand total}}

  • Flashcards, Pass: 5060100=30\frac{50 \cdot 60}{100}=30
  • Flashcards, Fail: 5040100=20\frac{50 \cdot 40}{100}=20
  • Practice tests, Pass: 5060100=30\frac{50 \cdot 60}{100}=30
  • Practice tests, Fail: 5040100=20\frac{50 \cdot 40}{100}=20

Step 4: Compute the chi-square statistic

χ2=(OE)2E\chi^2=\sum \frac{(O-E)^2}{E}χ2=(3630)230+(1420)220+(2430)230+(2620)220\chi^2= \frac{(36-30)^2}{30}+ \frac{(14-20)^2}{20}+ \frac{(24-30)^2}{30}+ \frac{(26-20)^2}{20}χ2=3630+3620+3630+3620=1.2+1.8+1.2+1.8=6.0\chi^2= \frac{36}{30}+\frac{36}{20}+\frac{36}{30}+\frac{36}{20} =1.2+1.8+1.2+1.8=6.0

Step 5: Find the degrees of freedom

df=(r1)(c1)=(21)(21)=1df=(r-1)(c-1)=(2-1)(2-1)=1

Step 6: Make the decision

With χ2=6.0\chi^2=6.0 and df=1df=1, the p-value is about 0.014. If α=0.05\alpha=0.05, then p<0.05p<0.05, 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.

mistakes

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
(row total)(column total)grand total\frac{(\text{row total})(\text{column total})}{\text{grand total}}In a goodness-of-fit test, expected counts often come from E=npiE=np_i​.

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:

Related statistical tests:

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

Scroll to Top