Chi-square calculator.
Run a chi-square goodness-of-fit test. Enter your observed and expected counts as comma-separated lists and the calculator returns the chi-square statistic, the degrees of freedom and the p-value.
Observed and expected
LiveChi-square is the sum of (observed minus expected) squared, divided by expected. Degrees of freedom is the number of categories minus one.
Chi-square statistic
4.000
sum of (O – E)^2 / E
A goodness-of-fit test that assumes independent counts and expected values above about 5 per category. Calculations run in your browser; nothing you enter is stored.
How it works
Observed versus expected
The chi-square goodness-of-fit test asks whether a set of observed counts differs from what a model expects. For each category you take the difference between observed and expected, square it, divide by the expected count, and add up the results.
A larger chi-square means a bigger gap between data and model. The p-value then says how likely a gap that big is by chance alone, given the degrees of freedom, which is the number of categories minus one.
Reference
Critical chi-square values.
The chi-square value you must exceed for significance at alpha 0.05, by degrees of freedom.
| Degrees of freedom | Critical value (0.05) |
|---|---|
| 1 | 3.841 |
| 2 | 5.991 |
| 3 | 7.815 |
| 4 | 9.488 |
| 5 | 11.070 |
| 6 | 12.592 |
The full guide
The complete guide to the chi-square test.
What the statistic measures, how to read the p-value, and when the test applies.
What the chi-square statistic measures
The chi-square statistic sums the squared, scaled gaps between observed and expected counts. Each term is (observed minus expected) squared over expected, so categories where the data is far from the model contribute the most.
A statistic near zero means the data matches the model closely; a large statistic signals a real discrepancy worth investigating.
Degrees of freedom and the p-value
Degrees of freedom for a goodness-of-fit test is the number of categories minus one. The statistic and the degrees of freedom together fix the p-value, which is the probability of seeing a chi-square at least this large if the model were true.
A small p-value, usually below 0.05, means the observed counts are unlikely under the model, so you reject the idea that the data fits.
Goodness of fit versus independence
This calculator runs a goodness-of-fit test, comparing observed counts to expected counts you supply. A related chi-square test of independence checks whether two categorical variables are associated, using a contingency table, and computes its expected values from the row and column totals.
The arithmetic is the same; only how you get the expected values differs.
When the test is valid
The chi-square test assumes independent observations and counts, not percentages or means. A common rule is that every expected count should be about 5 or more; with very small expected counts an exact test is better.
Use raw frequencies, check your expected values, and make sure each observation falls in exactly one category.
The formula
Observed
vs expected.
Chi-square sums (O minus E) squared over E across categories; the p-value comes from the chi-square distribution with categories minus one degrees of freedom.
P-value calculator ›# Chi-square goodness of fit
chi2 = sum( (O - E)^2 / E )
df = categories - 1
# example
(90-75)^2/75 + (30-25)^2/25 = 4.0Questions
Chi-square questions.
How do I calculate chi-square?
+
For each category, subtract expected from observed, square it, and divide by expected, then add the terms. Enter your observed and expected counts above and the calculator does it and gives the p-value.
What is a good chi-square p-value?
+
A p-value below 0.05 usually means the observed counts differ significantly from the expected, so the model does not fit. Above 0.05, the data is consistent with the model.
What are degrees of freedom here?
+
For a goodness-of-fit test, degrees of freedom equals the number of categories minus one. With two categories, that is one degree of freedom.
What is the difference between goodness of fit and independence?
+
Goodness of fit compares observed counts to expected counts you provide. A test of independence checks whether two variables are related, deriving expected values from a contingency table.
Is this chi-square calculator free?
+
Yes. It is completely free with no sign-up, and every calculation runs locally in your browser, so nothing you enter is stored or sent anywhere.
About the developer
Jean Borg
Jean builds and maintains every calculator on freecalculators.pro from Malta, with a focus on tools that are fast, free and show their working. The chi-square calculator uses the standard goodness-of-fit formula with an exact p-value.