CCalculate.Studio

χ² Chi-Square Test Calculator

This calculator runs a chi-square goodness-of-fit test, which compares a list of observed category counts against a list of expected counts to test whether the observed frequencies differ significantly from what was expected. It reports the χ² statistic, degrees of freedom and p-value, and flags statistical significance at the conventional α = 0.05 level. For example, observed counts of 30, 25, 22, 23 against equal expected counts of 25 each give χ² ≈ 1.52 with 3 degrees of freedom — not statistically significant.

Terakhir ditinjau: 2026-07-07

Understanding your chi-square result

The table below lists the standard chi-square critical values at the conventional α = 0.05 significance level for common degrees of freedom. An observed χ² statistic exceeding the listed value indicates a statistically significant departure from the expected distribution.

Degrees of freedom (df)Critical χ² at α = 0.05
13.841
25.991
37.815
49.488
511.070
612.592
815.507
1018.307
  • A widely used rule of thumb (found in standard statistics texts) is that the chi-square approximation is reliable when every expected count is at least 5; with smaller expected counts, an exact test is more appropriate.
  • This calculator performs goodness-of-fit only — a single categorical variable against a hypothesized distribution — not the chi-square test of independence between two categorical variables, which uses a different (row-by-column) expected-count calculation.
  • The observed and expected lists must have the same length, with at least 2 categories and every expected count strictly positive.
  • A statistically significant result indicates the categories differ from the hypothesized proportions; it does not by itself indicate which category, or how large the practical difference is.

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

The chi-square goodness-of-fit test compares the observed counts in a set of categories against the counts that would be expected under a hypothesized distribution, and measures how much they diverge. This calculator performs the goodness-of-fit version only — a single categorical variable checked against expected proportions — and not the related chi-square test of independence, which examines the association between two categorical variables in a contingency table.

The test statistic sums the squared, scaled difference between each observed and expected count across all categories: larger differences relative to the expected counts produce a larger χ² value and stronger evidence against the hypothesized distribution.

Because χ² is always zero or positive, the test is inherently one-directional: only unusually large χ² values (relative to the chi-square distribution with the appropriate degrees of freedom) are treated as evidence of a poor fit — there is no equivalent of a 'negative' direction to test against.

How to use this chi-square test calculator

  1. Enter the observed counts for each category as a comma-separated list, for example 30, 25, 22, 23.
  2. Enter the expected counts for the same categories, in the same order, as a comma-separated list, for example 25, 25, 25, 25.
  3. Ensure both lists have the same length (at least 2 categories) and that every expected count is greater than zero.
  4. Read the χ² statistic, degrees of freedom (number of categories minus 1), and p-value, and compare the p-value to your chosen significance level (commonly α = 0.05).

The formula behind the chi-square goodness-of-fit test

χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ
df = k − 1 (k = number of categories)
p-value = P(χ²_df ≥ observed χ²)
Example: observed 30,25,22,23 vs expected 25 each → χ²=1.52, df=3, p ≥ 0.05

The chi-square statistic is χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ, summed over all k categories, where Oᵢ is the observed count and Eᵢ is the expected count in category i. The degrees of freedom equal k − 1, one less than the number of categories.

The p-value is the probability of observing a χ² statistic at least as large as the one calculated, under the chi-square distribution with the given degrees of freedom, if the hypothesized (expected) distribution were true.

Worked example: observed counts 30, 25, 22, 23 against expected counts of 25 each. χ² = (30−25)²/25 + (25−25)²/25 + (22−25)²/25 + (23−25)²/25 = 1 + 0 + 0.36 + 0.16 = 1.52, with df = 4 − 1 = 3. This is well below the critical value of 7.815 for α = 0.05 at 3 degrees of freedom, so the result is not statistically significant.

Common mistakes

  • Using this goodness-of-fit test when the real question involves two categorical variables and their association — that requires a chi-square test of independence with a contingency table of expected counts, not a single observed-versus-expected list.
  • Violating the expected-count guideline: when expected counts are small (commonly below 5 in one or more categories), the chi-square approximation becomes unreliable and an exact test is more appropriate.
  • Entering observed and expected lists of different lengths, or listing categories in a different order in each list, which misaligns the comparison.
  • Entering an expected count of zero, which makes the (O − E)² / E term for that category undefined.
  • Treating a statistically significant χ² as evidence of a large or important difference — significance indicates the deviation is unlikely to be due to chance, not that it is practically large.

Pertanyaan yang sering diajukan

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

It tests whether the observed counts in a set of categories match a hypothesized distribution's expected counts — for example, checking whether a die's observed roll frequencies match the expected uniform distribution, or whether survey responses match an assumed proportion.

How is the chi-square statistic calculated?

χ² = Σ (observed − expected)² / expected, summed across every category. Larger discrepancies between observed and expected counts, especially relative to the expected count, produce a larger χ² value.

What are the degrees of freedom in a goodness-of-fit test?

Degrees of freedom equal the number of categories minus 1 (df = k − 1). For 4 categories, as in the worked example on this page, df = 3.

Why do expected counts need to be at least 5?

The chi-square test statistic's distribution is only approximated well by the chi-square distribution when expected counts are not too small. A commonly cited rule of thumb requires every expected count to be at least 5; below that, the p-value from the chi-square approximation can be inaccurate and an exact test is preferred.

Is this the same as a chi-square test of independence?

No. This calculator performs the goodness-of-fit test, which compares one categorical variable's observed counts to a hypothesized distribution. The test of independence examines whether two categorical variables are associated, using a contingency table where expected counts are computed from row and column totals — a different calculation.

Referensi

  1. Pearson K. On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philosophical Magazine Series 5, 1900; 50(302): 157-175.
  2. National Institute of Standards and Technology (NIST). NIST/SEMATECH e-Handbook of Statistical Methods — chi-square goodness-of-fit test. nist.gov.
  3. Moore DS, McCabe GP, Craig BA. Introduction to the Practice of Statistics. W. H. Freeman (chi-square goodness-of-fit test and expected-count guidelines).
  4. Snedecor GW, Cochran WG. Statistical Methods. Iowa State University Press (chi-square goodness-of-fit test).
  5. Agresti A. Categorical Data Analysis. Wiley (chi-square goodness-of-fit and independence tests).

Statistik · Semua kalkulator

Kalkulator terkait