Chi-Square Test Calculator

Chi-square goodness-of-fit and test of independence for counts: χ² statistic, degrees of freedom, p-value, critical value and an expected-count check.

Whole-number counts for each category. Use a point for decimals (1.5), no thousands separators, and separate numbers with spaces or a comma and a space.
One value per category: expected counts, proportions or a ratio such as 9, 3, 3, 1. They are scaled to the total of your observed counts. Leave empty to expect equal counts.
%
Usually 5%. The decision is "reject" when the p-value is below α.

Results

p-value
0.925426
p ≥ α (0.05), so the result is not statistically significant.
Chi-square statistic (χ²)
0.47
Degrees of freedom
3
Decision
Do not reject the null hypothesis
At α = 5% the counts are consistent with the expected distribution.
Critical value at α = 5%
7.8147
Reject when χ² is larger than this.
Expected-count check
All expected counts are 5 or more, so the chi-square approximation is reliable.

How it’s calculated

The chi-square test compares observed counts with the counts you would expect if the null hypothesis were true. The bigger the gaps, the bigger χ² and the smaller the p-value.

χ² = Σ (Observed − Expected)² ÷ Expected Goodness of fit: df = (number of categories) − 1 Independence: expected = (row total × column total) ÷ grand total, df = (rows − 1)(columns − 1) p-value = probability that χ² (with df degrees of freedom) is at least as large as observed

Goodness of fit asks whether one set of counts matches a claimed distribution, such as a fair die or a genetic ratio. Leave "expected" empty for equal counts, or enter proportions or a ratio; they are scaled to your total. Independence asks whether two categorical variables (the rows and columns of a table) are related. The test needs expected counts of at least 5 in (most) cells, and the calculator warns when they are smaller. It uses the standard Pearson formula with no Yates continuity correction, even for 2 × 2 tables.

Example (Mendel's peas, ratio 9:3:3:1): observed 315, 108, 101, 32, total 556, so the expected counts are 312.75, 104.25, 104.25, 34.75. χ² = 2.25²/312.75 + 3.75²/104.25 + 3.25²/104.25 + 2.75²/34.75 = 0.470 with 3 degrees of freedom, p = 0.925. That is well above 0.05, so the data fit the 9:3:3:1 ratio. As a check on the tables, χ² = 3.841 with 1 degree of freedom gives p ≈ 0.05.

Frequently asked questions

What does the p-value tell me?

It is the chance of seeing counts at least this far from the expected ones if the null hypothesis (the counts follow the expected pattern, or the two variables are unrelated) were true. A p-value below your α, usually 0.05, is evidence against it.

What if some expected counts are below 5?

The chi-square approximation becomes unreliable. Combine neighbouring categories, collect more data, or for a 2 × 2 table consider an exact test. The calculator flags this under "Expected-count check".

How are the degrees of freedom worked out?

Goodness of fit has (categories − 1). A test of independence has (rows − 1) × (columns − 1). If you estimated parameters of the distribution from the same data, subtract one more for each parameter; this calculator does not do that automatically.

Does this use a continuity correction (Yates) for 2 × 2 tables?

No. The χ² shown is the standard Pearson statistic with no Yates continuity correction. For a 2 × 2 table with small counts the correction (or an exact test) can give a somewhat larger p-value.

Can I enter percentages or proportions as the expected values?

Yes. Expected values are treated as relative weights and scaled to the total of the observed counts, so 25, 25, 25, 25 and 1, 1, 1, 1 both mean "equal". Observed values must be actual counts, not percentages.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator