The chi-square test handles questions about categories, where the data is counts rather than measurements.
Typical questions are whether the choice of plan depends on region, or whether a die is fair.
It works on a contingency table, which counts how often each combination of categories occurs.
Expected counts come from the row and column totals, assuming the 2 variables are unrelated.
For each cell, the expected count is the row total times the column total, divided by the grand total.
Each cell then contributes the squared gap between observed and expected, divided by the expected count.
The sum of those parts is the chi-square statistic, and larger values mean larger departures from independence.
The degrees of freedom are the number of rows minus 1, times the number of columns minus 1.
A goodness of fit version compares one set of counts with a fixed expectation, such as equal sales on each weekday.
The test needs counts of independent units, not percentages or repeated answers from the same people.
Small expected counts make it unreliable, and Fisher's exact test is a common alternative for small tables.
A significant result says the variables are related, not how strongly or in which cells.
Comparing observed and expected counts cell by cell shows where the difference comes from.
In practice, chi-square tests are common in survey analysis and in comparing conversion counts between groups.
The usual mistake is running the test on percentages instead of counts, which gives a meaningless result.