chi-square goodness of fit calculator

Chi-Square Goodness of Fit Calculator

Enter your observed counts and either expected counts or expected proportions. The calculator returns the chi-square statistic, degrees of freedom, p-value, and a decision at your chosen significance level.

If you provide expected counts, expected proportions below are ignored.
Use this when you know probabilities instead of expected frequencies.
Degrees of freedom = categories - 1 - estimated parameters.

What is the chi-square goodness of fit test?

The chi-square goodness of fit test checks whether observed category counts match a hypothesized distribution. You compare what you observed in your sample to what you would expect if the null hypothesis were true.

Typical use cases include testing whether a die is fair, whether customer choices follow expected market shares, or whether genetic outcomes follow Mendelian ratios.

Formula used in this calculator

The test statistic is:

χ² = Σ (Oi - Ei)² / Ei

  • Oi = observed count in category i
  • Ei = expected count in category i

Under the null hypothesis, this statistic follows approximately a chi-square distribution with:

df = k - 1 - m

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

How to use this calculator

Option A: Expected counts are known

Enter observed counts and expected counts with the same number of categories.

Option B: Expected proportions are known

Enter observed counts and expected proportions (for example, 0.1, 0.2, 0.3, 0.4). The tool multiplies those proportions by your total sample size to get expected counts.

Choose significance level

Most analyses use α = 0.05, but you can choose 0.01 or another threshold based on your context.

Interpreting results

  • Small p-value (p < α): reject the null hypothesis. Your observed distribution differs significantly from expected.
  • Large p-value (p ≥ α): fail to reject the null hypothesis. Data are reasonably consistent with the expected distribution.

Failing to reject does not prove the distribution is true; it means you do not have strong evidence against it with the current sample.

Assumptions and checks

  • Categories are mutually exclusive.
  • Observations are independent.
  • Expected counts should generally be at least 5 in most categories for the approximation to work well.

Worked example

Suppose a snack company claims four flavors are selected equally often. In a sample of 100 purchases, observed counts are 18, 22, 25, and 35. If all flavors are equally likely, expected counts are 25 each. The chi-square statistic is computed from each category’s contribution, and a small p-value would indicate flavor preferences are not equal.

Common mistakes

  • Using percentages without converting to expected counts correctly.
  • Mismatched category counts between observed and expected values.
  • Ignoring estimated parameters when calculating degrees of freedom.
  • Interpreting p-value as the probability the null hypothesis is true.

When to use a different test

Use a chi-square test of independence when you have two categorical variables in a contingency table. Use exact methods (like Fisher’s exact test or simulation approaches) when expected counts are too small for chi-square approximation.

🔗 Related Calculators