Chi Test Calculator

This chi test calculator computes the chi-square test statistic, degrees of freedom and p-value for a goodness-of-fit or independence test.

Checks on your data

  • All expected counts are at least 5, so the chi-square approximation is appropriate.
  • Use counts, not percentages. The test also assumes independent observations.

Results

Chi-square test statistic χ²
4.32
Degrees of freedom
3
p-value
0.228919
Decision
Fail to reject H₀ at α = 0.05
Critical value at α = 0.05
7.81473
Test
Goodness-of-fit test
Cells with expected count below 5
0 of 4
all expected counts are at least 5
χ² distribution (df = 3): shaded = p-value
510χ² = 4.32χ²
Contribution of each cell to χ² ((O − E)²/E)
00.511.5Category 1: 1.96Category 11.96Category 2: 0.36Category 20.36Category 3: 1Category 31Category 4: 1Category 41
Observed, expected and contribution
CellObserved OExpected E(O − E)²/E
Category 118251.96
Category 222250.36
Category 330251
Category 430251
Show step-by-step solution
  1. Expected counts: total ÷ categories (or your proportions × total).
  2. χ² = Σ (O − E)² ÷ E = 4.32.
  3. df = categories − 1 = 3.
  4. p = P(χ²(3) ≥ 4.32) = 0.228919.
StatisticΣ (O−E)²/E
GOF dfk − 1
Independence df(r−1)(c−1)
NeedsE ≥ 5

What Is Chi Test?

The chi-square test compares observed counts with the counts you would expect under a null hypothesis. The chi-square test statistic is χ² = Σ (O − E)² ÷ E, summed over every category or cell, and a large value means the observed counts are far from the expected ones.

Choose goodness of fit for one categorical variable, with equal or custom expected proportions, or independence for a two-way table. The calculator returns the chi test statistic, degrees of freedom, p-value, critical value and decision, and shows each cell's contribution so you can see which categories drive the result. It also warns when expected counts are below 5.

The sections below explain the formulas, variables, a worked example and answers to common chi-square questions.

How to Use the Chi Test Calculator

  1. Choose goodness of fit or independence.
  2. Enter observed counts (and optional expected values or proportions).
  3. Choose α.
  4. Read the statistic, degrees of freedom, p-value and the per-cell contributions.

Chi Test Formula

Chi-square statistic

χ2=∑(O−E)2E\chi^2=\sum\frac{(O-E)^2}{E}

Expected count in a two-way table

E=row total×column totalgrand totalE=\frac{\text{row total}\times\text{column total}}{\text{grand total}}

Chi Test Variables Explained

SymbolMeaningNotes
OObserved count in a cell
EExpected count under H₀
χ²Chi-square test statisticΣ (O − E)² ÷ E
dfDegrees of freedomk − 1 or (r − 1)(c − 1)

Chi Test Worked Example

A die-like spinner is spun 100 times with counts 18, 22, 30 and 30. If all four outcomes are equally likely, each expected count is 25. χ² = (18 − 25)²/25 + (22 − 25)²/25 + (30 − 25)²/25 + (30 − 25)²/25 = 1.96 + 0.36 + 1 + 1 = 4.32. With 3 degrees of freedom the p-value is about 0.229, so the data are consistent with equal probabilities.

With the example values loaded in the calculator above, the steps are:

  1. Expected counts: total ÷ categories (or your proportions × total).
  2. χ² = Σ (O − E)² ÷ E = 4.32.
  3. df = categories − 1 = 3.
  4. p = P(χ²(3) ≥ 4.32) = 0.228919.

Result: Chi-square test statistic χ² = 4.32; Degrees of freedom = 3; p-value = 0.228919.

How to Read a Chi-Square Test

The statistic χ² adds up (observed − expected)² ÷ expected over all cells. A spinner spun 100 times with counts 18, 22, 30 and 30 and equal expected counts of 25 gives χ² = (49 + 9 + 25 + 25) ÷ 25 = 4.32, with 3 degrees of freedom.

The p-value is about 0.229, and the 5% critical value for 3 degrees of freedom is 7.815. Since 4.32 is below it, there is no evidence against equal chances. The table of contributions shows which cells drive the statistic, so you can see where observed counts differ most from expected ones.

Where Chi Test Is Used

Goodness of fit

Test whether counts match a stated distribution, such as equal chances on a spinner.

Independence

Test whether two categorical variables are related using a table of counts.

Finding the driving cells

Use the contribution table to see which cells differ most from expectation.

Checking validity

See how many cells have an expected count below 5.

Common Chi Test Mistakes to Avoid

  • Use counts, not percentages. The test depends on the sample size.
  • Expected counts should usually be at least 5. The calculator flags cells below that.
  • Degrees of freedom are categories − 1 for goodness of fit and (rows − 1)(columns − 1) for independence.
  • A significant result says the variables are related. It does not say how strongly or why.

Chi Test Terms and Definitions

Observed count
The number actually seen in a category.
Expected count
The number predicted by the null hypothesis.

Chi Test FAQs

How do you calculate the chi-square test statistic?

For each cell compute (observed − expected)² ÷ expected, then add them all. For counts 18, 22, 30 and 30 against 25 each, the total is 4.32.

What is the difference between goodness of fit and independence?

Goodness of fit compares one set of counts with a stated distribution. Independence uses a two-way table to test whether two variables are associated.

How do I find the degrees of freedom?

For goodness of fit it is the number of categories minus 1. For a contingency table it is (rows − 1) × (columns − 1).

When is the chi-square test not valid?

When expected counts are too small, usually below 5 in many cells, or when the observations are not independent. In those cases combine categories or use an exact test.

Related calculators

Last updated 2026-11-09. See our disclaimer.