Statistics · Live
Chi-square test calculator,
straight from your raw data.
Run a goodness-of-fit test against an expected distribution, or a test of independence on a contingency table — enter your observed data and get the chi-square statistic, degrees of freedom, and p-value instantly.
*Expected can be a raw count or a proportion/ratio (e.g. 1 for each of 6 equally-likely dice faces) — it's automatically scaled to match your total observed count.
Chi-square statistic
3.2
Degrees of freedom
5
p-value
0.669183
Not significant at α = 0.05
Per-cell contribution to χ²
| O | E | (O−E)²/E |
|---|---|---|
| 8 | 10 | 0.4 |
| 11 | 10 | 0.1 |
| 7 | 10 | 0.9 |
| 14 | 10 | 1.6 |
| 9 | 10 | 0.1 |
| 11 | 10 | 0.1 |
Guide
What is a chi-square test, and who uses it?
A chi-square (χ²) test answers a simple question about categorical data: is the pattern you observed likely to be real, or could it easily have happened by chance? Researchers, analysts, and students reach for it constantly — checking whether a survey's answer distribution matches expectations, whether a die or coin is fair, whether two demographic groups respond differently to a treatment, or whether a marketing campaign's conversion rate actually varies by channel. Unlike this site's P-value Calculator, which converts a chi-square statistic you've already worked out by hand into a p-value, this tool runs the whole test — you enter your raw counts, and it computes the statistic, degrees of freedom, and p-value all in one step.
Goodness-of-fit vs. independence
Both modes use the exact same formula, just on differently shaped data:
Goodness-of-fit tests one categorical variable against an expected distribution. The classic example: roll a die 60 times and expect 10 of each face if it's fair. Your actual counts (say, 8, 11, 7, 14, 9, 11) are the observed values; 10 each is expected. A small χ² means your rolls are close to what fairness predicts; a large one suggests the die might be loaded.
Test of independence checks whether two categorical variables are related, using an r×c contingency table. Say 50 patients get a treatment and 50 get a placebo, and you record how many in each group improved. The expected count for each cell is derived from the row and column totals — if treatment and outcome were truly unrelated, that's the split you'd expect to see. Degrees of freedom differ between the two modes: k − 1 for goodness-of-fit (k categories), (r − 1)(c − 1) for independence.
Reading the output
The chi-square statistic itself doesn't mean much on its own — it needs to be judged against its degrees of freedom, which is exactly what the p-value does. A p-value below your chosen significance level (commonly 0.05) means the difference between observed and expected is unlikely to be random noise, and you'd reject the hypothesis that they match (or that the two variables are independent). A p-value above that threshold means the data is consistent with random variation — you don't have strong evidence of a real effect. The per-cell breakdown this calculator shows alongside the overall statistic is worth checking too: it tells you which specific category or table cell is driving most of the χ² total, not just that something, somewhere, doesn't match.
When chi-square isn't the right test
The chi-square approximation relies on expected counts being large enough for the underlying math to hold — the usual rule of thumb is that every expected count should be at least 5. When a cell falls below that (common with small samples or many categories), the test can give misleading p-values. In that situation, combine adjacent categories to raise the expected counts, collect more data, or switch to Fisher's exact test, which handles small samples correctly instead of relying on chi-square's large-sample approximation.
Disclaimer
This calculator implements the standard chi-square goodness-of- fit and independence test formulas. It is provided for educational and general analytical use; for research intended for publication or high-stakes decisions, verify results against dedicated statistical software and consult a statistician where appropriate.