AI Glossary / Statistics and probability / Intermediate

Pearson's chi-square ( c 2 )

Definition

Pearson's chi-square is a statistic that compares observed counts with counts expected under a specified null hypothesis. It sums squared differences divided by expected counts. Common applications include testing whether categorical variables are independent and whether a set of category counts fits specified probabilities. Its usual chi-square reference distribution is an approximation whose suitability depends on the design and expected counts.

What it means

The statistic asks how far a table departs from a model of expected frequencies. Larger departures produce a larger value because positive and negative differences cannot cancel after squaring.
The term refers to a family of count-based comparisons, not to Pearson's correlation coefficient. A statistically detectable departure does not tell you whether the difference is commercially important, which categories explain it, or what caused it.

How it works

Start with mutually exclusive categories, a clear sampling unit, and an appropriate null model. Count each independent unit according to the design. Repeated measurements, matched pairs, clusters, and survey weights require methods that account for their structure.
For an independence test in a two-way table, calculate each expected count as its row total multiplied by its column total and divided by the grand total. Sum (observed minus expected) squared divided by expected across cells.
For a goodness-of-fit test, multiply the sample size by each null category probability to obtain expected counts. The probabilities must describe the intended reference model and normally sum to one.
For a standard independence table with r rows and c columns, the degrees of freedom are (r minus 1) times (c minus 1). For a goodness-of-fit test with fully specified probabilities, they are usually the number of categories minus one. Estimating parameters from the same data can change that reference calculation.
Compare the statistic with the upper tail of the appropriate chi-square distribution when the approximation is justified. Sparse expected counts can make the approximation unreliable; an exact or properly designed simulation method may be preferable.
Document corrections and software settings. For example, SciPy's contingency-table function applies Yates' correction by default when the degrees of freedom equal one. An uncorrected calculation and a corrected calculation need not return the same p-value.
Examine observed proportions, residual patterns, effect sizes, and uncertainty alongside the overall test. A significant omnibus result does not automatically identify every individual category comparison as significant.

Three practical examples

  • AI evaluation: a team compares pass and fail counts across independently sampled model outputs.
  • Customer research: analysts check whether preferred support channels differ across customer segments.
  • Quality assurance: a factory compares defect-category counts with a predeclared expected distribution.

Think of it this way

Think of a seating plan showing how many guests should occupy each section. Pearson's statistic measures the discrepancy between the planned and actual counts, while allowing the scale of each expected count to affect the comparison.

Worked example

Suppose two independently sampled groups each contain 50 cases. Group A has 30 successes and 20 failures; group B has 20 successes and 30 failures. Overall there are 50 successes, 50 failures, and 100 cases.
Under independence, each expected cell count is 50 × 50 / 100 = 25. The uncorrected statistic is four times 5 squared / 25, giving chi-square = 4. With (2 minus 1) × (2 minus 1) = 1 degree of freedom, its approximate upper-tail p-value is 0.0455.
The success proportions are 60% and 40%, a difference of 20 percentage points. For this two-by-two table, the magnitude of phi is sqrt(4/100) = 0.20.
These are deliberately uncorrected Pearson calculations. A continuity correction changes the statistic and p-value. The comparison also assumes independent cases; the same table would not justify this test if each A observation were paired with a B observation. None of these calculations establishes that group membership caused success.

Illustrative case study

Fictional case: Linden Support compares two independently sampled groups of completed customer-service sessions. An analyst reports a Pearson test alongside the actual success proportions and investigates whether session complexity differed between groups. Management uses the result to justify a controlled follow-up study, rather than treating the table as proof that one workflow caused better outcomes.

Common misconceptions and mistakes

Do not enter percentages as though they were original counts. The sample size matters for the reference calculation.
Do not confuse expected counts with observed counts when assessing sparse-table limitations. Avoid merging categories after inspecting results solely to obtain significance.
A small p-value is not an effect-size measure. Conversely, a large p-value does not prove independence or an exact fit to the null model.
The likelihood-ratio chi-square statistic uses a different formula. It should not be silently relabeled as Pearson's statistic.

Business use

Businesses can use the method to screen categorical differences, audit classifications, and compare outcome distributions. Useful reporting includes the table, sampling design, expected-count assessment, degrees of freedom, correction or simulation settings, effect sizes, and the decision the comparison informs.

People also ask

Does it work for numerical measurements?

Not directly in this count-table form; arbitrary binning can discard information.

Can it prove causation?

No. Causal interpretation depends on the study design and assumptions.

Must every application use the same minimum expected count rule?

No. Approximation quality and suitable alternatives depend on the table and method.

Check your understanding

Why does every expected cell equal 25 in the worked example?

Answer: Each row and column total is 50 out of 100.

What is missing from a p-value alone?

Answer: The size, direction, practical importance, and design limitations of the observed difference.

Related terms

  • Contingency table
  • Independence
  • Expected frequencies
  • Degrees of freedom
  • goodness-of-fit test
  • expected frequency
  • likelihood-ratio test
  • Cramer's V
  • Fisher's exact test

Learn next

Learn next how standardized residuals describe table departures, how effect sizes complement significance tests, and when exact or simulation-based procedures are appropriate for sparse counts.

More in Statistics and probability

  • Partialing - Partialing, also spelled partialling, is statistically adjusting for one or more variables when examining relationships among other variables.
  • Partially open question - A partially open question is a survey question that combines structured response options with an opportunity to answer in the respondent's own words.
  • Pearson correlation coefficient - The Pearson correlation coefficient measures the direction and strength of linear association between two quantitative variables.
  • Per-comparison error rate - The per-comparison error rate is the Type I error probability associated with an individual hypothesis test: rejecting that test's null hypothesis when it...
  • Per-word entropy - Per-word entropy expresses uncertainty in a word-generating process on an average-per-word basis.
  • Percentage of agreement - Percentage of agreement is the percentage of comparable observations for which two or more assessments match, under an explicitly stated agreement rule.

Sources

Sources: SciPy, chi2_contingency documentation, https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2_contingency.html ; SciPy, chisquare documentation, https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chisquare.html . These primary software references describe expected counts, reference assumptions, degrees of freedom, and implementation options. The numerical example and fictional case are original illustrations.

Previous: Pearson correlation coefficient Next: PEAS

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer