The Chi-Square Statistic
AP Statistics · Unit 3 — Inference for Categorical Data: Proportions
One formula, three uses
$$\chi^2=\sum\frac{\left(O-E\right)^2}{E}$$where $O$ is the observed count and $E$ the count expected if $H_0$ were true. Dividing by $E$ is what makes a discrepancy of $12$ matter a lot against an expectation of $30$ and almost nothing against an expectation of $3000$.
Always counts, never percentages. Feeding proportions into the formula gives a meaningless number.
Condition: every expected count $\ge5$. Observed counts may be small; it is the expected ones that must not be.
The distribution is right-skewed, values are non-negative, and the P-value is always the upper tail — a large $\chi^2$ means observed and expected are far apart.
Worked example: computing expected counts
A $2\times3$ table has row $1$ total $80$, column $2$ total $60$, and grand total $200$. Compute the expected count for the cell (row 1, column 2).
Solution
The formula for the expected count in a two-way table:
$$E=\frac{\text{row total}\times\text{column total}}{\text{grand total}}=\frac{80\times60}{200}=24$$Meaning: if the two variables are independent, row $1$ makes up $\frac{80}{200}=40\%$ of the whole, so it should also make up $40\%$ of column $2$, that is, $0.4\times60=24$.
An expected count need not be a whole number — it is a theoretical average and can easily come out as $24.6$.