The choice of test depends on the data and the question. A z-test is appropriate when the population standard deviation is known or the sample is large, whereas a t-test is used when the population standard deviation is unknown and must be estimated from the sample. An independent samples t-test compares the means of two unrelated groups, while a paired t-test compares two related measurements on the same subjects (such as before-and-after observations). Degrees of freedom, often \(n - 1\) for variance estimates, describe the number of values free to vary after constraints are imposed.
When comparing three or more groups, ANOVA (analysis of variance) tests whether any group means differ, using an F-statistic that contrasts between-group variance with within-group variance. A significant ANOVA indicates that at least one mean differs, but it does not say which; post-hoc tests such as Tukey's HSD perform the necessary pairwise comparisons. For categorical data, the chi-square test of independence assesses whether two categorical variables are associated, while the chi-square goodness-of-fit test checks whether observed frequencies match expected proportions. When distributional assumptions like normality are doubtful, non-parametric tests offer robust alternatives: the Mann-Whitney U test compares two independent samples, the Wilcoxon signed-rank test handles paired samples using ranks, and the Kruskal-Wallis test generalizes to several groups, paralleling one-way ANOVA.