t-Tests
Overview
A t-test compares a sample mean to a hypothesized value or compares means between groups. The one-sample t-test compares a single group to a known value. The two-sample t-test compares means of two independent groups. The paired t-test compares means from the same subjects measured twice (before/after). Welch's t-test is the robust default that doesn't assume equal variances. All t-tests assume independence and approximate normality (critical for small samples). For large samples (), the CLT ensures validity even without strict normality. Always report effect size (Cohen's d) alongside p-values to communicate practical significance.
Key Concepts
t-Test Selection Guide
| Scenario | Test | scipy Function | df Formula |
|---|---|---|---|
| Sample mean vs. known value | One-sample | ttest_1samp(x, mu0) | |
| Two independent groups (equal var) | Pooled | ttest_ind(x, y, equal_var=True) | |
| Two independent groups (unequal var) | Welch's | ttest_ind(x, y, equal_var=False) | Satterthwaite |
| Same subjects measured twice | Paired | ttest_rel(x, y) |
Assumptions
- Independence: Observations must be independent. No clustering or repeated measures (use paired instead).
- Normality: Data (or differences for paired) should be approximately normal. Critical for small samples ().
- Equal Variances (pooled only): Test with Levene's test. When in doubt, use Welch's.
- Continuous Data: Dependent variable on interval or ratio scale.
- No Significant Outliers: Check with boxplots or Cook's distance.
Quick Example
Key Takeaways
Deep Dive
For detailed explanations, worked examples, and Python implementations, explore the dedicated statistics lessons:
Z-Test
- One-Sample Z-Test β When Ο is known; the simplest hypothesis test for a mean
t-Tests
- One-Sample t-Test β Comparing a sample mean to a hypothesized value with worked examples
- Two-Sample t-Test β Comparing means of two independent groups (pooled and Welch's)
- Paired t-Test β Before/after studies and matched pairs analysis
Related Topics
- F-Test for Equality of Variances β Testing whether two groups have equal variances
- Levene's Test β Robust test for homogeneity of variances
- Hypothesis Testing β The foundational framework behind all t-tests
- Power of a Test β Determining sample size needed to detect a given effect
- Effect Size β Cohen's d, Hedges' g, and practical significance
- One-Way ANOVA β Extending t-test to 3+ groups (ANOVA with 2 groups = tΒ²)