🎲 Chi-Square Test Calculator
Enter observed and expected counts (goodness-of-fit) or a contingency table (independence) to get the χ² statistic, df, p-value and verdict.
χ² statistic
1
Degrees of freedom
5
p-value
0.9626
Not significant at α = 0.05
p = 0.9626 ≥ 0.05: the observed counts are consistent with the expected distribution.
The chi-square test compares observed counts to what a hypothesis predicts: χ² = Σ (O − E)² ÷ E. Goodness-of-fit checks whether one categorical variable follows an expected distribution (df = categories − 1); the independence test checks whether two variables in a contingency table are related (df = (rows − 1)(cols − 1), with expected counts from the row and column totals). It needs counts, not percentages, and expected counts should generally be 5 or more. 🔒 In your browser.
How the chi-square test calculator works
The chi-square test compares observed counts with the counts a hypothesis predicts: χ² = Σ (observed − expected)² ÷ expected. In goodness-of-fit mode you supply observed and expected counts for one categorical variable (df = categories − 1). In independence mode you paste a contingency table and the tool derives the expected counts from the row and column totals, testing whether the two variables are related (df = (rows − 1)(columns − 1)). It converts χ² to an exact p-value.
The test needs raw counts, not percentages, and the usual rule of thumb is that expected counts should be at least 5 in each cell for the approximation to hold. A significant result (p below α) means the observed pattern departs from the hypothesis — a poor fit, or an association between the variables — but chi-square shows that a relationship exists, not how strong it is or which direction.
Frequently asked questions
How do I calculate a chi-square test?
For each category or cell, take (observed − expected)², divide by expected, and sum: χ² = Σ (O − E)² ÷ E. Then find the degrees of freedom and convert χ² to a p-value using the chi-square distribution. The tool does all of this from your counts.
What is the difference between goodness-of-fit and independence?
Goodness-of-fit tests whether one categorical variable matches an expected distribution (e.g. is a die fair?). The test of independence uses a two-way table to check whether two categorical variables are associated (e.g. is preference related to age group?).
How are the expected counts found in a test of independence?
For each cell, expected = (its row total × its column total) ÷ grand total — the count you'd see if the two variables were completely independent. The tool computes and can display the full expected table.
What are the degrees of freedom for a chi-square test?
For goodness-of-fit, categories − 1. For a test of independence on an r×c table, (r − 1) × (c − 1). Degrees of freedom set the shape of the chi-square distribution used to get the p-value.
What does a significant chi-square result mean?
That the observed counts differ from what the hypothesis predicts more than chance would explain — the distribution doesn't fit, or the two variables are associated. It doesn't measure how strong the association is; for that, look at effect-size measures like Cramér's V.