What Is Chi Test?
The chi-square test compares observed counts with the counts you would expect under a null hypothesis. The chi-square test statistic is χ² = Σ (O − E)² ÷ E, summed over every category or cell, and a large value means the observed counts are far from the expected ones.
Choose goodness of fit for one categorical variable, with equal or custom expected proportions, or independence for a two-way table. The calculator returns the chi test statistic, degrees of freedom, p-value, critical value and decision, and shows each cell's contribution so you can see which categories drive the result. It also warns when expected counts are below 5.
The sections below explain the formulas, variables, a worked example and answers to common chi-square questions.
How to Use the Chi Test Calculator
- Choose goodness of fit or independence.
- Enter observed counts (and optional expected values or proportions).
- Choose α.
- Read the statistic, degrees of freedom, p-value and the per-cell contributions.
Chi Test Formula
Chi-square statistic
Expected count in a two-way table
Chi Test Variables Explained
| Symbol | Meaning | Notes |
|---|---|---|
| O | Observed count in a cell | |
| E | Expected count under H₀ | |
| χ² | Chi-square test statistic | Σ (O − E)² ÷ E |
| df | Degrees of freedom | k − 1 or (r − 1)(c − 1) |
Chi Test Worked Example
A die-like spinner is spun 100 times with counts 18, 22, 30 and 30. If all four outcomes are equally likely, each expected count is 25. χ² = (18 − 25)²/25 + (22 − 25)²/25 + (30 − 25)²/25 + (30 − 25)²/25 = 1.96 + 0.36 + 1 + 1 = 4.32. With 3 degrees of freedom the p-value is about 0.229, so the data are consistent with equal probabilities.
With the example values loaded in the calculator above, the steps are:
- Expected counts: total ÷ categories (or your proportions × total).
- χ² = Σ (O − E)² ÷ E = 4.32.
- df = categories − 1 = 3.
- p = P(χ²(3) ≥ 4.32) = 0.228919.
Result: Chi-square test statistic χ² = 4.32; Degrees of freedom = 3; p-value = 0.228919.
How to Read a Chi-Square Test
The statistic χ² adds up (observed − expected)² ÷ expected over all cells. A spinner spun 100 times with counts 18, 22, 30 and 30 and equal expected counts of 25 gives χ² = (49 + 9 + 25 + 25) ÷ 25 = 4.32, with 3 degrees of freedom.
The p-value is about 0.229, and the 5% critical value for 3 degrees of freedom is 7.815. Since 4.32 is below it, there is no evidence against equal chances. The table of contributions shows which cells drive the statistic, so you can see where observed counts differ most from expected ones.
Where Chi Test Is Used
Goodness of fit
Test whether counts match a stated distribution, such as equal chances on a spinner.
Independence
Test whether two categorical variables are related using a table of counts.
Finding the driving cells
Use the contribution table to see which cells differ most from expectation.
Checking validity
See how many cells have an expected count below 5.
Common Chi Test Mistakes to Avoid
- Use counts, not percentages. The test depends on the sample size.
- Expected counts should usually be at least 5. The calculator flags cells below that.
- Degrees of freedom are categories − 1 for goodness of fit and (rows − 1)(columns − 1) for independence.
- A significant result says the variables are related. It does not say how strongly or why.
Chi Test Terms and Definitions
- Observed count
- The number actually seen in a category.
- Expected count
- The number predicted by the null hypothesis.
Chi Test FAQs
How do you calculate the chi-square test statistic?
For each cell compute (observed − expected)² ÷ expected, then add them all. For counts 18, 22, 30 and 30 against 25 each, the total is 4.32.
What is the difference between goodness of fit and independence?
Goodness of fit compares one set of counts with a stated distribution. Independence uses a two-way table to test whether two variables are associated.
How do I find the degrees of freedom?
For goodness of fit it is the number of categories minus 1. For a contingency table it is (rows − 1) × (columns − 1).
When is the chi-square test not valid?
When expected counts are too small, usually below 5 in many cells, or when the observations are not independent. In those cases combine categories or use an exact test.