Contents
Chi-Square Tests and ANOVA
The z and t tests handle means of numerical data. Chi-square tests work on counts in categories, while ANOVA compares means across three or more groups.
Chi-Square Test
χ² = Σ (O − E)² / E
- χ² (chi-square): the test statistic. A larger value means the observed counts are further from what H₀ predicts.
- O: the observed count in each category.
- E: the expected count in each category if H₀ were true.
- Σ (sigma): add the result across all categories.
The goodness-of-fit version checks whether counts match an expected pattern. The test of independence checks whether two categorical variables are related using a contingency table.
Example: 120 customers choose among three subscription plans. If all plans are equally popular, 40 would pick each. The observed counts are 50, 40 and 30. Test at α = 0.05.
- χ² = (50 − 40)² / 40 + (40 − 40)² / 40 + (30 − 40)² / 40 = 2.5 + 0 + 2.5 = 5
- Degrees of freedom = 3 categories − 1 = 2, and the critical value at 0.05 is 5.991.
- Since 5 < 5.991, fail to reject H₀. The p-value is about 0.082.
The differences between plans could easily be random variation.
ANOVA
Running many t-tests across several groups raises the chance of a false positive. Analysis of variance (ANOVA) tests all the group means in one step. H₀ says all group means are equal, and H₁ says at least one differs.
F = variance between groups/variance within groups
- F: the test statistic. A value near 1 means the groups differ no more than random noise would produce.
- Variance between groups: how far each group mean sits from the overall mean.
- Variance within groups: how much individual values vary inside each group.
A large F with a small p-value means at least one group mean is different, but it does not say which. A follow-up test is needed to identify which groups differ.
Probability and Statistics for Data Science
Abhishek Pati








