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.
Where Chi Test Is Used
Goodness of fit
Testing whether counts match a claimed distribution.
Association
Testing whether two categorical variables are independent.
Survey analysis
Comparing response counts across groups.
Coursework
Checking chi-square statistics and p-values.
Common Chi Test Mistakes to Avoid
- Use raw counts.
- Check that expected counts are at least 5.
- A significant result does not say which cells differ; look at the contributions.
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?
Sum (observed − expected)² ÷ expected over all categories or cells.
What is the difference between goodness of fit and independence?
Goodness of fit compares one variable with a distribution; independence tests for an association between two variables.
How do I find the degrees of freedom?
k − 1 for goodness of fit; (rows − 1) × (columns − 1) for independence.
When is the chi-square test not valid?
When expected counts are very small or observations are not independent.