calculator for chi square

Chi-Square Goodness-of-Fit Calculator

Enter observed and expected counts for each category. The calculator returns the chi-square statistic, degrees of freedom, p-value, and decision at your chosen significance level.

Category Observed (O) Expected (E) Action

What this chi-square calculator does

This tool computes the chi-square goodness-of-fit test, which helps you check whether observed category counts match a hypothesized distribution. If your observed data are very different from expected values, the chi-square statistic becomes larger and the p-value becomes smaller.

Typical use cases include dice fairness tests, survey response patterns, genetics ratios, and any count-based data where categories are mutually exclusive.

The core formula

The test statistic is:

χ2 = ∑ ((O - E)2 / E)

  • O = observed count in a category
  • E = expected count in that category
  • The sum runs across all categories

The result is compared against a chi-square distribution with the appropriate degrees of freedom.

Degrees of freedom

For goodness-of-fit, a common formula is:

df = k - 1 - m

  • k = number of categories
  • m = number of model parameters estimated from the same data

If you did not estimate parameters from your sample for the expected distribution, use m = 0.

How to use this calculator

  1. Enter each category name, observed count, and expected count.
  2. Add or remove categories as needed.
  3. Set estimated parameters (usually 0 for simple classroom examples).
  4. Set alpha (commonly 0.05).
  5. Click Calculate Chi-Square.

The output includes statistic value, p-value, and decision: reject or fail to reject the null hypothesis.

Interpreting your result

Null hypothesis (H0)

The observed frequencies follow the expected distribution.

Alternative hypothesis (H1)

The observed frequencies do not follow the expected distribution.

  • If p < alpha: reject H0 (evidence of mismatch).
  • If p ≥ alpha: fail to reject H0 (not enough evidence of mismatch).

Assumptions and best practices

  • Data are counts, not percentages or means.
  • Categories are independent and mutually exclusive.
  • Expected counts should generally be large enough (rule of thumb: most ≥ 5).
  • Expected totals should match observed total for standard goodness-of-fit testing.

Common mistakes to avoid

  • Using negative counts or expected counts of zero.
  • Forgetting to adjust degrees of freedom when parameters were estimated.
  • Treating non-significant results as proof that distributions are exactly equal.
  • Applying chi-square to tiny expected counts without caution.

Goodness-of-fit vs. chi-square test of independence

This calculator is designed for goodness-of-fit (one variable, many categories). A chi-square test of independence is used for contingency tables (two categorical variables). Both use chi-square distributions, but expected counts are computed differently.

Quick example

Suppose a six-sided die is rolled 120 times. Under fairness, each side has expected count 20. If your observed counts differ from 20 each, plug in those values and calculate. A small p-value indicates evidence the die may not be fair.

🔗 Related Calculators

🔗 Related Calculators