Chi-Square Calculator

Form

Results

χ2

0
1

What is Chi-Square?

This calculator finds the contribution of one observed count and one expected count to a chi-square statistic. It is useful when you are working through a frequency table by hand and want to check each row before adding the results.

The distinction between one contribution and a complete test matters. This page accepts only one pair of numbers. It does not collect a full table, calculate degrees of freedom, or return a p-value. The number on screen describes that pair's contribution; by itself it cannot tell you whether a hypothesis should be rejected.

2

How to Use This Calculator

Enter the observed frequency in Observed value. This is the actual number counted in a category. Enter the expected frequency in Expected value: the count implied by the model you are testing, rather than a target chosen after seeing the result.

Expected counts must be greater than zero. An observed count may be zero, because a category can be possible under the model even when none of the observations fell into it. Run the calculation separately for each category, keeping a record of the contribution and category name. Add all relevant contributions to obtain the full statistic for a goodness-of-fit calculation.

3

Formula Used

Contribution = (O − E)² / E, where O is the observed count and E is the expected count. For several categories, χ² = Σ[(Oᵢ − Eᵢ)² / Eᵢ].

Subtract expected from observed, square the difference, and divide by expected. Squaring removes the sign, so both an excess and a shortfall can increase the statistic. Dividing by the expected count also changes the scale: a difference of 5 contributes 2.5 when E is 10, but only 0.25 when E is 100. The raw difference alone is therefore not enough to judge a category's contribution.

4

Variables Explained

VariableMeaning in this calculator
Observed count, OThe count recorded for one category. Use counts from the same sample and classification rules as the expected value.
Expected count, EA strictly positive count implied by the null model. It may be fractional even when actual observations are whole numbers.
ContributionThe nonnegative quantity (O − E)²/E. The page formats it to four decimal places.
Full statistic, χ²The sum across all relevant categories or table cells. This page does not perform that sum automatically.
Degrees of freedomNeeded for interpreting a complete statistic. This calculator has no degrees-of-freedom input or p-value output.
5

Worked Example

Suppose 30 observations are divided into three categories. A model predicts 10 in each, while the observed counts are 12, 8 and 10. For the first category, (12 − 10)²/10 = 4/10 = 0.4. The page displays 0.4000.

For the second, (8 − 10)²/10 is also 0.4. For the third, (10 − 10)²/10 is zero. Adding the three contributions gives χ² = 0.8. Both the observed and expected counts total 30, which is a useful consistency check before interpreting the statistic.

If all expected probabilities were specified in advance and no parameters were estimated from these data, this three-category goodness-of-fit example has two degrees of freedom. That additional information belongs to the complete test, not to the individual 0.4 contribution.

6

Why Use This Calculator?

Larger contributions identify categories with a greater discrepancy on this scale. They can help you inspect a frequency table, but they do not explain why the discrepancy occurred. A sampling issue, an unsuitable model or ordinary variation may produce differences.

For a formal test, also consider independence of observations, category definitions and whether expected counts are sufficient for the chi-square approximation. Small expected counts need particular care. Choosing an appropriate exact method or a justified regrouping of categories requires more information than this two-field calculator contains.

7

Common Mistakes

    Do not enter percentages where your calculation requires frequencies. Twelve percent of 50 and twelve percent of 5,000 are different counts and contain different amounts of information. Similarly, an expected probability of 0.2 must be multiplied by the sample size before it becomes an expected count.

    Never use zero as the denominator. The current form does not reliably prevent this invalid case. Do not discard categories just because their contributions are inconvenient, and keep unrounded contributions when adding many cells; repeated rounding can change the final total.

8

Frequently Asked Questions

Can the contribution be negative?

Not with a positive expected count. The numerator is a square, so the result is zero or positive. A negative answer would indicate an invalid expected input or a different calculation.

Why did counts 12 and 8 give the same contribution against 10?

Both are two observations away from the expectation. Squaring gives four in either direction, and both calculations divide by the same expected count of ten.

Does a result of zero prove that the model is correct?

No. It says this category matched its expected count exactly. Other categories may differ, and even a small complete statistic does not prove the underlying model is true.

Can I use this for a contingency table?

You can check each cell contribution after calculating the expected count from its row total, column total and grand total. You must still add all cells and use the appropriate test assumptions and degrees of freedom.

9

Sources & References