Chi-Square Goodness of Fit Calculator

Compare observed category counts with expected frequencies and calculate the chi-square statistic, degrees of freedom, and p-value.

Goodness-of-fit test
Enter matching comma-separated lists of observed and expected frequencies.

About chi-square goodness of fit

A chi-square goodness-of-fit test compares observed category frequencies with frequencies predicted by a theory, historical model, or specified probability distribution. It addresses a single categorical variable. The null hypothesis states that the population follows the proposed category proportions, while the alternative states that at least one category proportion differs. Common applications include checking whether a die is fair, whether customer choices follow a forecast, or whether genetic outcomes match a proposed ratio. The calculator pairs each observed count with the expected count in the same position. For every category it computes (observed − expected)² / expected, then sums those contributions to obtain the chi-square statistic. A value of zero means every observed frequency exactly matches its expectation. Larger values indicate greater overall disagreement, with differences in categories having smaller expected counts receiving relatively more weight. Degrees of freedom are normally the number of categories minus one when all expected proportions were specified independently of the current data. If parameters were estimated from the observations, additional degrees of freedom must be subtracted. This calculator uses categories minus one, so analysts fitting distribution parameters should adjust their methodology accordingly. The p-value is the upper-tail probability of the calculated statistic under the corresponding chi-square distribution. Before using the test, ensure observations are independent, categories are mutually exclusive, and inputs are counts rather than percentages. Expected frequencies should generally be at least five for the chi-square approximation to perform well. Categories with small expected values may sometimes be combined when that combination is scientifically meaningful and decided without reference to the observed differences. Otherwise, an exact or simulation-based test may be preferable. A small p-value indicates that the observed deviations would be unusual if the proposed distribution were correct. It does not identify which categories drive the result, establish a causal explanation, or measure practical significance. Inspect each cell's contribution and compare observed with expected values to understand the pattern. Also choose the significance level before looking at results and consider whether multiple testing affects interpretation. Expected frequencies should represent the same total number of observations as the observed frequencies. If expected probabilities are available instead, multiply each probability by the observed total before entering them. Minor differences in totals caused by rounding should be corrected so that the model and sample refer to the same count. Used with these checks, the goodness-of-fit calculator provides a transparent and reproducible summary of how closely categorical data follow a proposed model.

Goodness-of-fit examples

Each row compares observed counts with a fully specified expected distribution.

Observed vs. expectedTest resultInterpretation
20,20,20 vs. 20,20,20χ² = 0, df = 2, p = 1The observed and expected distributions match exactly.
10,20,30 vs. 20,20,20χ² = 10, df = 2, p ≈ 0.00674Equal category frequencies are not well supported.
48,52 vs. 50,50χ² = 0.16, df = 1, p ≈ 0.689The small deviation is consistent with a 50/50 model.

How to calculate goodness of fit

  1. List observed counts in a consistent category order.
  2. List the positive expected counts in exactly the same order.
  3. Select Calculate Goodness of Fit to compute the test results.
  4. Compare the p-value with your preselected significance level and inspect category differences.

Goodness-of-fit FAQ

Must observed and expected totals match?

Yes, both lists should describe the same total number of observations. Convert expected probabilities to counts and correct rounding before running the test.

How are degrees of freedom calculated?

The default is the number of categories minus one. Subtract additional degrees of freedom when parameters were estimated from the same observations.

Can expected frequencies be zero?

No, division by an expected count is part of every category contribution. A model assigning zero probability to an observed category requires a different analytical treatment.

What if expected counts are below five?

The chi-square approximation may be unreliable for sparse categories. Consider a justified category combination or an exact simulation-based goodness-of-fit test.

What does a significant result tell me?

It indicates the data are inconsistent with the proposed distribution at the chosen threshold. It does not by itself explain the discrepancy or show that it matters in practice.