Chi-Square Test Calculator

Run a chi-square goodness-of-fit test or test of independence.

Observed counts

Expected proportions (%)

Optional: leave empty for uniform expected counts.

Enter at least two categories (or a valid table).

How the chi-square test works

The chi-square test compares observed counts to the counts expected under a hypothesis. The goodness-of-fit version tests whether a set of observed frequencies matches a specified distribution. The test of independence tests whether two categorical variables are related, using a contingency table.

The χ² statistic sums the squared differences between observed and expected counts, each divided by the expected count. Larger values mean more evidence against the null hypothesis.

Degrees of freedom are k − 1 for goodness-of-fit and (rows − 1)(columns − 1) for independence. The p-value is the upper tail of the chi-square distribution.

The formula

χ² = Σ (O − E)² / E

For goodness-of-fit, expected counts are the total times the hypothesized proportions (or uniform when none are given). For independence, expected counts are row total × column total ÷ grand total. The p-value is the upper tail of the chi-square distribution with the appropriate degrees of freedom.

Worked example

A 2×2 table [[30, 10], [10, 30]]

Row and column totals are 40 and 40, so every expected count is 20. χ² = 4 × (30−20)²/20 = 20 with 1 degree of freedom, giving a p-value far below 0.001 — strong evidence of association.

Frequently asked questions

What assumptions does the chi-square test make?

Observations must be independent, and the expected frequency in each cell should generally be at least 5 for the approximation to be reliable. With sparse tables consider exact methods.

What is the difference between the two modes?

Goodness-of-fit tests whether observed counts match expected proportions. Independence tests whether two categorical variables are related in a contingency table.

Why is a small expected count a problem?

The chi-square distribution approximates the test statistic well only when expected counts are not too small; very small expected counts inflate χ² and make the p-value unreliable.

Built by PanelRoster

PanelRoster is an enterprise operations management platform for organizations coordinating distributed teams, assignments, workflows, quality assurance and operational execution.

Explore PanelRoster