Chi-Square Calculator
Compute the chi-square statistic and p-value for goodness-of-fit or independence tests.
Enter the same number of values in each box, separated by commas, spaces, or new lines. Every expected value must be greater than zero.
Chi-Square (χ²)
Degrees of Freedom
P-Value
Per-Category Contributions
| # | Observed (O) | Expected (E) | O − E | (O − E)² / E |
|---|
The Goodness-of-Fit Test
The chi-square goodness-of-fit test checks whether an observed frequency distribution differs from a theoretical (expected) distribution. The test statistic is χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ, summed over all categories. A larger χ² means the observed counts deviate more from what was expected.
Observed vs Expected
Observed frequencies are the counts you actually measured in each category. Expected frequencies are the counts predicted by your null hypothesis — for example, equal proportions across categories or proportions derived from a known model. The two lists must have the same number of categories, and every expected value must be positive.
Degrees of Freedom & Assumptions
- Degrees of freedom: for a goodness-of-fit test with k categories, df = k − 1.
- P-value: the right-tailed probability from the chi-square distribution. If p ≤ α, the difference is statistically significant.
- Expected counts: the test is most reliable when each expected count is at least 5. Small expected counts can distort the result.
- Independence: observations should be independent and each fall into exactly one category.