Chi-square test
A chi-square test is a statistical hypothesis test that uses a chi-square-distributed statistic to evaluate hypotheses about categorical data, goodness of fit, or variance.
Statistics Slam Dunk
A chi-square test is a statistical test based on a chi-square-distributed statistic for assessing categorical-data relationships or distributional differences.
- How it is used
- Tests whether categorical variables such as prior rest and game outcomes are related.
- How deep it goes
- Defines independence hypotheses and p-value decisions, then demonstrates running chisq.test() on a contingency table.
- Examples
- Uses NBA days off versus wins and losses, survey sentiment versus marital status, political beliefs, and restaurant customer counts.
- What you can do after
- Apply it via base R’s chisq.test() to assess categorical relationships from a contingency table.
Effective Data Analysis
A chi-square test is a statistical test that evaluates categorical data by comparing observed frequencies with frequencies expected under a specified hypothesis.
- How it is used
- Uses categorical comparisons when both independent and dependent variables are categorical.
- How deep it goes
- Explains test variants, observed-versus-expected frequencies, contingency tables, calculations, and pairwise follow-up comparisons.
- Examples
- Demonstrates recommender versions, countries, user clicks, expected-frequency tables, Python output, and an observed-versus-expected heatmap.
- What you can do after
- Apply it via SciPy to compare categorical frequencies and inspect expected counts, p-values, and cell-level differences.
Statistics Every Programmer Needs
A chi-square test is a statistical hypothesis test that compares observed categorical counts with expected counts to assess whether their discrepancy is statistically significant.
- How it is used
- Tests whether observed leading-digit counts conform to Benford’s law for anomaly detection and statistical validation.
- How deep it goes
- Derives expected counts, the chi-square statistic, degrees of freedom, and p-value interpretation, while requiring sufficient records.
- Examples
- Uses leading digits in world population counts, with tabulated observed counts, expected counts, and category contributions.
- What you can do after
- Diagnose whether categorical counts significantly depart from an expected distribution using Python’s SciPy implementation.
Read how Statistics Every Programmer Needs explains chi-square test →
Related concepts
- hypothesis testingkind of · Hypothesis testing is a formal statistical procedure that uses observed data to evaluate evidence about a specified hypothesis, often a null hypothesis.
- non-parametric testkind of · A non-parametric test is a statistical test that evaluates evidence without requiring a specified parametric distributional form for the data.
- categorical datauses · Categorical data consists of values representing membership in a discrete set of named or ordered categories rather than measured numerical magnitudes.
- contingency tableuses · A contingency table is a tabular summary of counts or other measures for combinations of categories from two or more categorical variables.
- t-testcontrasts with · A t-test is a statistical hypothesis test that uses a t-distributed statistic to assess a mean or difference in means under specified assumptions.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


