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.

Where Chi Test Is Used

Goodness of fit

Testing whether counts match a claimed distribution.

Association

Testing whether two categorical variables are independent.

Survey analysis

Comparing response counts across groups.

Coursework

Checking chi-square statistics and p-values.

Common Chi Test Mistakes to Avoid

  • Use raw counts.
  • Check that expected counts are at least 5.
  • A significant result does not say which cells differ; look at the contributions.

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?

Sum (observed − expected)² ÷ expected over all categories or cells.

What is the difference between goodness of fit and independence?

Goodness of fit compares one variable with a distribution; independence tests for an association between two variables.

How do I find the degrees of freedom?

k − 1 for goodness of fit; (rows − 1) × (columns − 1) for independence.

When is the chi-square test not valid?

When expected counts are very small or observations are not independent.

Related calculators

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