Loading…

A Goodness of Fit Test

Statistics • Chi Square Tests

View all topics

Use a chi-square goodness-of-fit test to check whether observed category counts follow a claimed distribution. This is a right-tailed test based on the statistic χ².

Decision uses p-value and/or the critical value χ²1−α.

The rejection region is in the right tail of the χ² distribution.

Categories table

Enter observed counts O for each category. Then provide either proportions p or expected counts E. The calculator computes χ² and the decision.

# Category Observed O Proportion p Expected E (O−E) (O−E)2/E Actions
Totals:
Quick checks
Add at least 2 categories.

When this method applies

  1. There are k > 2 categories (possible outcomes).
  2. The data are counts from n identical trials or observations.
  3. The outcomes are treated as independent.
  4. Under H₀, the category probabilities remain constant, so E = n · p.
Core formulas
\[ \begin{aligned} E_i &= n\cdot p_i \\ \chi^2 &= \sum_{i=1}^{k}\frac{(O_i-E_i)^2}{E_i} \\ df &= k-1 \end{aligned} \]
Practical check: each expected count should be at least 5. If not, results may be unreliable.
Hypotheses (generic)
\[ \begin{aligned} H_0 &: \text{The observed distribution matches the expected proportions.}\\ H_1 &: \text{The observed distribution does not match the expected proportions.} \end{aligned} \]
Decision rule
Right tail only: reject H₀ if χ² is large. You may decide by p-value (p ≤ α) or by critical value (χ² ≥ χ²1−α).
Ready
χ² model visualization (right tail)
0
After calculation: blue shading approximates the p-value area to the right of χ², and red shading shows the rejection region at level α.

Output notes

Expected frequency rule
If one or more expected counts are below 5, the chi-square approximation may be poor. Consider combining categories or collecting more data.
Degrees of freedom
This calculator uses df = k − 1 (no parameters estimated from the sample). If your expected probabilities depend on estimated parameters, df would be smaller.
Copy-friendly
Use the copy buttons to move the summary, the computed table, or your category data between devices/files.
Enter your categories and click Calculate.
Paste / export category data as CSV

Paste a simple table to fill the categories. Header is optional. Supported formats:
category,observed,p (proportions mode)
category,observed,expected (expected-counts mode)
You may also paste observed,p or observed,expected without category names.

Rate this calculator

0.0 /5 (0 ratings)
Be the first to rate.
Your rating
You can update your rating any time.

Frequently Asked Questions

What is a chi-square goodness-of-fit test used for?

It tests whether observed counts across categories follow a claimed probability distribution. If the mismatch is large, the chi-square statistic becomes large and the right-tail p-value becomes small.

How do I calculate expected counts for a goodness-of-fit test?

When expected proportions are given, compute each expected count as E_i = n x p_i, where n is the total number of observations. The calculator can also use equal proportions p_i = 1/k or accept expected counts directly.

Why is the goodness-of-fit test right-tailed?

The chi-square statistic sums squared deviations scaled by expected counts, so it is always nonnegative. Larger values indicate poorer fit, so the rejection region is in the right tail.

What degrees of freedom does the calculator use for chi-square goodness of fit?

It uses df = k - 1, where k is the number of categories, assuming the expected probabilities are fully specified. If parameters are estimated from the sample to form p_i, the correct df would be smaller.

What if some expected counts are less than 5?

A common guideline is that each expected count should be at least 5 for the chi-square approximation to be reliable. If expected counts are small, consider combining categories or collecting more data.