Chi-Square Test Calculator
Run a chi-square goodness-of-fit test from observed and expected frequencies — get the χ² statistic, degrees of freedom, and p-value.
Result
- χ² statistic20.000000
- Degrees of freedom3
- p-value0.000170
- SignificanceHighly significant (p < 0.001)
- Largest contributorcategory 1 (9.000)
Step-by-step
- For each category compute (O − E)² / E and sum: χ² = 20.0000.
- Degrees of freedom = categories − 1 = 4 − 1 = 3.
- p-value = P(χ²(3) > 20.0000) = 0.0002 → Highly significant (p < 0.001).
How to use this calculator
- Enter the observed frequencies (your actual counts), comma-separated.
- Enter the expected frequencies under the null hypothesis, in the same order.
- Read the χ² statistic, degrees of freedom, and p-value.
- Compare the p-value to your significance level (e.g. 0.05) to decide.
About this calculator
The chi-square goodness-of-fit test checks whether a set of observed category counts matches what you would expect under some hypothesis — for example, whether a die is fair, or whether outcomes are evenly distributed. For each category it computes the squared difference between the observed and expected count, divided by the expected count, and sums these into the chi-square statistic. A larger statistic means the observed data departs further from expectation. Comparing the statistic to the chi-square distribution with degrees of freedom equal to the number of categories minus one yields a p-value: the probability of seeing a discrepancy this large if the null hypothesis were true. A small p-value (commonly below 0.05) is evidence that the observed distribution genuinely differs from the expected one.
How it works — the formula
χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ
df = k − 1 (k = number of categories)
p = P(χ²_df > χ²_observed)Each category contributes its standardized squared deviation from expectation; the sum is compared to the chi-square distribution to get a tail probability.
Worked examples
- Inputs:
- observed=10,20,30,40; expected=25,25,25,25
- Output:
- χ²=20, df=3, p≈0.00017
- Inputs:
- observed=8,9,10,11,12,10; expected=10,10,10,10,10,10
- Output:
- χ²=1.0, df=5, p≈0.96
- Inputs:
- observed=30,20; expected=25,25
- Output:
- χ²=2.0, df=1, p≈0.157
Limitations
- Goodness-of-fit only; not a test of independence (contingency tables).
- Expected counts should each be ≥ 5 for the approximation to hold.
- Sensitive to total-count mismatches between observed and expected.
Inferential test; conclusions depend on a correctly specified null hypothesis.