The T-Test › Why Do We Need the T-Test?

Michael BrenndoerferJanuary 3, 20262 min read
Machine Learning from ScratchAll chapters
Part 2 of 9Hypothesis Testing
Chapter 15The T-Test › Why Do We Need the T-Test?
Reading section 2 of 11 · Why Do We Need the T-Test? · 2 minSection 2 of 11 · 2 min

Book contents

Section 2 of 11 · 2 min read

The T-Test › Why Do We Need the T-Test?One section · Sections in this chapter2 / 11 ↓
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

In the previous chapter on z-tests, we learned to compare means when the population standard deviation σ\sigma is known. The test statistic was:

z=xˉ−μ0σ/nz = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}

This follows a standard normal distribution because the denominator σ/n\sigma / \sqrt{n} is a fixed, known quantity. Only the numerator varies from sample to sample.

The problem is that you almost never know σ\sigma. In practice, you estimate the standard deviation from your sample data, giving you the sample standard deviation ss. Early researchers simply substituted ss for σ\sigma and continued using normal distribution critical values. This seemed reasonable, but it led to systematic errors. They rejected the null hypothesis more often than they should have, especially with small samples.

Gosset discovered why: when you estimate σ\sigma from the same sample you're testing, you introduce additional variability into the test statistic. The sample standard deviation ss is itself a random variable that fluctuates from sample to sample. Sometimes ss underestimates σ\sigma, making your test statistic too large. Sometimes ss overestimates σ\sigma, making it too small. This extra variability means the test statistic no longer follows a normal distribution. It follows a distribution with heavier tails, one that appropriately penalizes us for not knowing the true population variance.