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.

Inputs

Counts you actually observed, separated by commas.

Counts expected under the null hypothesis. Must match the observed count.

Result

Chi-square statistic (χ²)
20.0000
df 3 · p = 0.0002 · Highly significant (p < 0.001)
  • χ² statistic20.000000
  • Degrees of freedom3
  • p-value0.000170
  • SignificanceHighly significant (p < 0.001)
  • Largest contributorcategory 1 (9.000)
Note — Goodness-of-fit test: compares one observed distribution to expected counts. Each expected count should be ≥ 5 for the χ² approximation to be reliable. A small p-value means the observed counts differ significantly from expectation.

Step-by-step

  1. For each category compute (O − E)² / E and sum: χ² = 20.0000.
  2. Degrees of freedom = categories − 1 = 4 − 1 = 3.
  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

Example 1
O=10,20,30,40 vs E=25,25,25,25
Inputs:
observed=10,20,30,40; expected=25,25,25,25
Output:
χ²=20, df=3, p≈0.00017
Example 2
Fair die O=8,9,10,11,12,10 vs E=10×6
Inputs:
observed=8,9,10,11,12,10; expected=10,10,10,10,10,10
Output:
χ²=1.0, df=5, p≈0.96
Example 3
O=30,20 vs E=25,25
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.

Frequently asked

It tests whether observed category counts differ significantly from expected counts. A small p-value means the difference is unlikely to be due to chance, so you reject the hypothesis that the data follows the expected distribution.

Related calculators

More tools you might like