Math calculator

Chi-Square Calculator

Goodness of fit and independence — with the expected counts you are supposed to check.

Observed against expected

Ratios can be proportions or raw weights — 9:3:3:1 works as well as 0.5625, 0.1875, 0.1875, 0.0625.

χ² = 1.0000, df = 5

0.962566

Not below α = 0.05: the counts are consistent with the null. Note this is a failure to detect a difference, not evidence the null is true.

χ²

1.0000

Σ (o − e)² ÷ e

df

5

categories − 1

Critical value

11.0705

upper tail at α = 0.05

Smallest expected

10.000

at least 5 — condition met

Where the statistic came from

Observed against expected for each cell, with its contribution to the total.
CellObservedExpected(o−e)²/eShare of χ²
Category 1810.0000.400040.0%
Category 2910.0000.100010.0%
Category 31210.0000.400040.0%
Category 41010.0000.00000.0%
Category 51110.0000.100010.0%
Category 61010.0000.00000.0%

The smallest EXPECTED count is 10.00, comfortably past 5, so the chi-square approximation is sound here. Note the condition is on expected counts — an observed zero is not itself a problem.

What this tool shows

The validity condition is stated on expected counts, not observed ones — an observed zero is fine if the cell expected twelve. Almost no calculator shows them, so the condition cannot be checked. This one prints observed, expected and each cell’s contribution to the total.

  • Goodness of fit against equal or specified ratios
  • Independence in any r × c contingency table
  • Every expected count, with the small ones flagged
  • Each cell’s contribution to the statistic
  • The critical value at your α
  • Cramér's V, which chi-square cannot give you
Expected counts shown Condition checked Per-cell contributions Cramér's V included

An omnibus test: it finds a departure, never which cell caused it.

Updated 8 September 2026 · Works in any browser, no installation

χ² = Σ (observed − expected)² / expected. Every cell contributes its squared miss, scaled by how big a miss would be surprising there. The two tests differ only in where the expected counts come from and how many degrees of freedom survive.

At a glance

Formula shown
χ² = Σ(o−e)²/e. Goodness of fit takes expected counts from stated ratios, with k−1 degrees of freedom. Independence takes them from the margins — rowTotal × colTotal / grandTotal — with (r−1)(c−1) degrees of freedom. The test is always one-tailed in the upper direction.
Scenario support
Testing whether a die or a random generator is fair; checking observed genetic ratios against Mendelian expectations; asking whether two categorical variables in a survey are related; comparing observed category counts against a published distribution.
Educational estimate
Planning support from the values you enter — not professional advice.

The condition is on expected counts, not observed ones

“Chi-square needs counts of at least 5” is remembered by almost everyone and misremembered by most of them.

The condition is on the EXPECTED counts. A cell that observed zero is entirely fine if the null predicted twelve for it — in fact that cell is the most interesting one in the table. A cell that expected 1.3 is a problem no matter how many landed in it.

The reason is what the approximation is doing. Chi-square treats a discrete count as though it were continuous, and that works when the expected count is large enough for the distribution of the miss to be roughly smooth. It is the expectation that sets the scale.

The usual form of the rule, from Cochran: no expected count below 1, and no more than 20% of cells below 5. The stricter “nothing below 5” is a simplification of it, and the tool reports both the minimum expected count and how many cells fall short so you can apply either.

When it fails, the p-value is not slightly optimistic — it can be substantially wrong, usually too small. The remedy is Fisher’s exact test, which computes the probability directly from the hypergeometric distribution and is valid at any cell count. It is called exact because it never approximates in the first place.

The other remedy is combining categories, which is legitimate but costs you resolution and must be decided before seeing the results rather than after.

It tells you a departure exists, not where

Chi-square is an omnibus test. A significant result says the observed counts are not consistent with the null, and that is the entire finding. It does not say which category or which cell drove it, and reading a direction into a bare chi-square is a genuine error.

The contribution column answers the question people actually ask next. Each cell’s (o−e)²/e is its share of the total, and one cell frequently accounts for most of it. That is the cell worth talking about, and the tool flags it when it exceeds half the statistic.

Two cautions on doing that, because it is a form of looking after the fact.

Contributions are unsigned. Squaring loses the direction, so a large contribution tells you a cell is far from expectation without saying which way. Compare observed against expected to recover it — both are printed for exactly this reason.

Picking out the largest cell is a second look at the same data. If you intend to make a formal claim about a particular cell rather than an informal one, the honest tools are standardised residuals with a multiple-comparison correction. Treating the biggest contributor as a tested result is the same error as subgroup hunting after a non-significant primary outcome.

Why the degrees of freedom are what they are

Degrees of freedom count how many cells you could still fill in freely once everything the test holds fixed has been fixed. Both formulas fall straight out of that.

Goodness of fit: k − 1. You have k categories, and the total is fixed by the data. Once you know any k−1 of the counts, the last is determined by subtraction. One constraint, one degree of freedom lost.

Independence: (r−1)(c−1). All the row totals and all the column totals are fixed. Fill in the top-left (r−1) × (c−1) block and every remaining cell is forced by the margins. In a 2×2 table that is a single free cell, which is why df = 1.

Estimated parameters cost more. If the expected counts required you to estimate something from the same data — fitting a Poisson and using the observed mean as λ, say — each estimated parameter costs another degree of freedom. This is easy to overlook and it makes the test too conservative when it happens the other way, or too liberal if you forget the subtraction.

The consequence of getting df wrong is not subtle, because the whole reference distribution changes. The critical value at α = 0.05 is 3.84 with 1 degree of freedom and 18.31 with 10 — a statistic of 12 is decisive under one and unremarkable under the other.

Why there is no lower critical value

The chi-square distribution is not symmetric and lives entirely on the non-negative numbers, which surprises people expecting a ± form.

The test is one-tailed in the upper direction only. Large χ² means observed and expected are far apart, which is evidence against the null. Small χ² means they agree closely, which is not evidence against anything.

So the whole of α goes in the upper tail even though the alternative hypothesis is not directional in the way a one-tailed t-test’s is. Those are different senses of “one-tailed” and conflating them is a common confusion.

There is one famous exception, and it is worth knowing because it inverts the usual reasoning. A suspiciously small chi-square — a fit far better than sampling variation should allow — is a recognised signal that data has been fabricated or over-cleaned. Fisher used precisely this argument to question Mendel’s pea results, which fit their expected ratios more closely than chance comfortably permits.

That is a diagnostic for data integrity rather than a hypothesis test, and it is the only setting in which the lower tail of a chi-square carries information.

Chi-square grows with sample size, so it cannot be compared

A property that makes the raw statistic misleading across studies.

χ² scales directly with n. Double every count in a table and the statistic doubles, while the pattern — the relative composition — has not changed at all. The p-value shrinks accordingly.

This is the same phenomenon the p-value page demonstrates for effects generally: with enough data, any departure from independence that is not exactly zero becomes significant. On a large survey a chi-square test will find nearly everything significant, and that is uninformative rather than impressive.

Cramér’s V is the standard fix. It divides the statistic by the sample size and the table’s shape, giving a number between 0 and 1 that measures the strength of association rather than the confidence that one exists. Doubling every count leaves V unchanged, which is exactly what an effect size should do.

The conventional reading is roughly 0.1 weak, 0.3 moderate, 0.5 strong, adjusted for degrees of freedom — and, as with every such scale, a domain yardstick beats it where one exists.

Report both. The p-value says whether the association is distinguishable from noise; V says whether it is large enough to care about. The tool prints V for contingency tables for this reason.

What the test requires of your data

Beyond the expected-count condition, three requirements — and the first is violated more often than the count rule everyone worries about.

Counts, not percentages or means. Chi-square operates on frequencies. Running it on percentages produces a number that depends entirely on whether you wrote 45 or 0.45, and the number is meaningless either way. If you only have percentages, recover the counts first.

Independent observations, each contributing to exactly one cell. This is the one that fails quietly. Measuring the same people twice — before and after — puts each person in two cells, and the test has no defence. That design needs McNemar’s test, which is built for paired categorical data.

Mutually exclusive, exhaustive categories. Every observation falls in exactly one cell, and the cells account for everything. A “select all that apply” survey question violates both halves and is one of the most common misuses in practice.

The pattern across all three: chi-square checks the arithmetic of a table without being able to see how the table was built. It will produce a confident number from a table that should never have been assembled.

Its relationship to the tests either side of it

Three connections, each of which saves work or prevents a wrong choice.

On a 2×2 table, chi-square is exactly the square of a two-proportion z. Not similar — identical, because chi-square with one degree of freedom is the distribution of a squared standard normal. The suites assert it: z² = 4.000000 = χ² with matching p-values on the same data. So if your z-test and a 2×2 chi-square disagree, one of them has an arithmetic error or a continuity correction the other lacks.

The one thing z can do that chi-square cannot is a one-tailed alternative. Squaring destroys the sign, so chi-square is inherently two-sided. If direction matters and was fixed in advance, use z.

Below the count condition, use Fisher’s exact test. It enumerates the hypergeometric probability of every table at least as extreme, so it is valid at any cell count. The cost is computational, which is why chi-square dominated while arithmetic was done by hand.

For paired categorical data, use McNemar’s. Chi-square requires each observation in one cell; before-and-after measurements on the same subjects break that, and McNemar tests the discordant pairs instead.

Sources and methodology

References for the test and for the count condition.

Method. Expected counts are computed from stated ratios for goodness of fit and from the margins for independence, and both are printed rather than kept internal — the validity condition is stated on them, so a calculator that hides them makes the condition uncheckable. The tail probability comes from the upper incomplete gamma evaluated directly rather than as 1 − CDF, so a large statistic does not underflow to p = 0. The suite asserts the identity this page rests on: on a 2×2 table the chi-square statistic equals the square of the two-proportion z, and the p-values match — checked across the engines rather than within one, which is what makes it a real cross-check. It also asserts that chi-square with 2 degrees of freedom is exactly the exponential distribution with rate 1/2, and that a squared standard normal is chi-square with 1. That engine is verified on every change against 0 assertions. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

z-testOne-proportion, two-proportion and known-sigma mean z-tests — with the t-test computed beside the mean case, because for a mean the z-test needs a σ almost nobody actually has.
Critical ValueCritical values for z, t, chi-square and F at any alpha and any degrees of freedom — with one- and two-tailed values shown together, because reading the wrong column of a printed table is the classic error.
p-valueA p-value from a t or z statistic, one- or two-tailed — with a panel that holds an effect fixed and grows the sample, so you can watch significance appear from nothing but n.
Hypergeometric DistributionExact probabilities for drawing without replacement, with the binomial answer beside them and the 10% rule evaluated — at a 40% sampling fraction the binomial is 22% wrong, at 0.2% it is 0.06% wrong.
Binomial DistributionExact binomial probabilities at any n — including thousands, where a factorial overflows — with the normal approximation beside them and its error measured, which is 0.6% at the centre and 261% in the tail.
t-testOne-sample, two-sample and paired t-tests defaulting to Welch, with Student's pooled version printed beside it — and a warning when the two disagree on the verdict.

More in Math, or browse all calculators.

Educational use disclaimer

An educational tool. Chi-square requires independent observations falling in exactly one cell each, and counts rather than percentages; it cannot detect a table that was assembled in a way that violates those, and will return a confident number regardless.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

  • Formula and examples verified on 8 September 2026
  • Self-reviewed — written and checked by the same person, with no independent reviewer
  • Educational estimate only
  • How calculators are verified
What's changed (3 updates)

Published 8 September 2026

  1. Published a chi-square calculator covering goodness of fit and independence, printing every expected count alongside the observed one — the validity condition is stated on expected counts, and a calculator that hides them makes it uncheckable.
  2. Corrects the condition as it is usually remembered: an observed zero is fine if the cell expected twelve, while a cell expecting 1.3 is a problem however many landed in it. The suite asserts both halves of that.
  3. Shows each cell's contribution to the statistic, because chi-square is an omnibus test that finds a departure without saying which cell caused it — and prints Cramér's V, since the statistic itself scales with sample size and cannot be compared across studies.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.