Statistical Inference › Common Statistical Tests
Machine Learning from ScratchAll chapters Statistical Inference › Common Statistical TestsOne section · Sections in this chapter5 / 8 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Statistical inference provides a rich toolkit of tests designed for different data types and research questions. Selecting the appropriate test requires understanding the data structure, distributional assumptions, and hypotheses being evaluated.
T-Tests: Comparing Means
T-tests evaluate hypotheses about population means and come in several variants. The one-sample t-test determines whether a population mean differs from a hypothesized value, such as testing whether average customer spending differs from $50. The independent samples t-test compares means between two separate groups, like comparing average test scores between students taught with different methods. The paired samples t-test analyzes differences within matched pairs, such as before-and-after measurements on the same individuals.
T-tests assume that data are approximately normally distributed, though moderate departures from normality usually have little effect, especially with larger sample sizes (typically n > 30). For severely non-normal data or small samples, nonparametric alternatives like the Wilcoxon tests may be more appropriate. T-tests also assume equal variances between groups for the independent samples variant, though Welch's t-test provides a modification that relaxes this assumption.
Chi-Square Tests: Analyzing Categorical Data
Chi-square tests evaluate relationships and distributions in categorical data. The chi-square goodness-of-fit test determines whether observed frequencies of categories match expected frequencies under some hypothesis. For example, we might test whether the distribution of customer age groups in our sample matches the known distribution in the general population.
The chi-square test of independence evaluates whether two categorical variables are independent or associated. When analyzing a contingency table of social media platform usage by age group, this test would determine whether platform preference depends on age or whether the variables are independent. The test compares observed cell frequencies to frequencies expected under independence, with large discrepancies providing evidence of association.
Chi-square tests require adequate sample sizes for valid inference. A common rule of thumb suggests expected frequencies should exceed 5 in each cell, though this guideline can be relaxed for larger tables. When expected frequencies are too small, exact tests like Fisher's exact test provide alternatives.
ANOVA: Comparing Multiple Groups
Analysis of variance (ANOVA) extends t-tests to compare means across three or more groups simultaneously. Rather than conducting multiple pairwise t-tests, which inflates Type I error rates, ANOVA tests the overall null hypothesis that all group means are equal against the alternative that at least one differs.
ANOVA partitions total variance into components: variance between groups (reflecting true differences in group means plus random error) and variance within groups (reflecting only random error). The F-statistic compares these variance components, with large values indicating that between-group variance exceeds what random chance alone would produce, suggesting real differences in population means.
When ANOVA rejects the null hypothesis, it indicates that not all means are equal but doesn't identify which specific groups differ. Post-hoc tests like Tukey's HSD provide pairwise comparisons while controlling family-wise error rates. ANOVA assumes normally distributed data within groups, equal variances across groups (homoscedasticity), and independent observations. Violations may require transformations or alternative approaches like Kruskal-Wallis tests.
Correlation Tests: Measuring Relationships
Correlation tests evaluate the strength and significance of relationships between continuous variables. Pearson correlation measures linear associations, producing correlation coefficients (r) ranging from -1 (perfect negative correlation) through 0 (no linear relationship) to +1 (perfect positive correlation). Hypothesis tests determine whether observed correlations differ significantly from zero, indicating population-level associations rather than random sample fluctuations.
Pearson correlation assumes bivariate normality and is sensitive to outliers. Spearman's rank correlation provides a nonparametric alternative that evaluates monotonic relationships using ranks rather than raw values, reducing the influence of outliers and making it appropriate for ordinal data. Both measures capture association strength, not causation: significant correlations may reflect confounding variables or reverse causality rather than direct causal effects.