← SciSim / Statistics
One-Sample t-Test
📊 Tier: Standard Undergraduate
§1 Interactive Simulation
μ₀ (null)
0.00
x̄ (sample)
s (std dev)
t statistic
p-value
df = n-1
μ₀ null mean 0
x̄ sample mean 1
s sample std dev 1
n sample size 20
α level 0.05
Tail type
§2 The Idea, Step by Step

Your favorite coffee shop swears its "large" holds 16 ounces. You buy a few, and each one feels a little light. Are you just unlucky, or is the shop really under-pouring? A one-sample t-test answers exactly that: does a small handful of measurements really disagree with one claimed number, or is the gap just everyday randomness?

The claim is the null mean $\mu_0$ (16 oz). Your measurements give a sample mean $\bar{x}$, they wobble by a standard deviation $s$, and you took $n$ of them. The trick is that the raw gap $\bar{x}-\mu_0$ means nothing on its own — it only matters compared with how noisy the cups are. So we divide the gap by the noise:

$$t = \frac{\bar{x}-\mu_0}{s/\sqrt{n}}$$

Say five cups average $\bar{x}=15.5$ oz, with spread $s=0.5$. The standard error is $s/\sqrt{n}=0.5/\sqrt{5}\approx 0.22$, so $t=(15.5-16)/0.22\approx -2.2$. The sample sits about two "noise units" below the claim — suspicious, but not yet a verdict.

THE PRECISE VERSION

Under the null hypothesis the statistic $t=(\bar{X}-\mu_0)/(S/\sqrt{n})$ follows Student's t-distribution with $df=n-1$. The denominator $S/\sqrt{n}$ is the standard error of the mean; dividing by it turns a difference measured in ounces (or any units) into a pure, unitless score. Because we estimated the true spread $\sigma$ with the sample value $S$, the reference curve has heavier tails than a normal — a penalty for our uncertainty that shrinks as $n$ (and $df$) grow. In the sim, the $\mu_0$, $\bar{x}$, $s$, and $n$ sliders move the gold test-statistic line and reshape the red curve, while $\alpha$ and the tail selector set the shaded rejection region.

Try this in the sim above:

1. Slide $n$ upward while holding $\bar{x}$, $s$, and $\mu_0$ fixed — watch $|t|$ grow and the p-value shrink, because more data sharpens the estimate.

2. Open the df Comparison tab and imagine $df=1$ — the tails balloon outward (the Cauchy case), so you need a far bigger $t$ to be convinced.

3. Push $s$ up and watch the same $\bar{x}-\mu_0$ gap stop being significant — noisy data hides real differences.

§3 Mathematical Derivation

One-Sample t-Test — William Gosset "Student", 1908

$$\boxed{t = \frac{\bar{X} - \mu_0}{S/\sqrt{n}} \sim t_{n-1} \quad \text{under } H_0}$$

Used when σ is UNKNOWN — uses sample standard deviation $S$.

Symbol Table

SymbolMeaningRangeNote
$\mu_0$Null hypothesis mean$(-\infty,\infty)$The hypothesized value
$\bar{X}$Sample mean$(-\infty,\infty)$Estimator of population mean
$S$Sample std dev$(0,\infty)$$S=\sqrt{\frac{\sum(X_i-\bar{X})^2}{n-1}}$
$n-1$Degrees of freedom$\mathbb{N}$One df lost estimating $\mu$
$t_{n-1}$Student t-distribution$(-\infty,\infty)$Heavier tails than normal; → normal as df→∞
KEY DERIVATION

Since $\sigma$ is unknown, replace it with $S$. The standardized statistic is no longer N(0,1). Instead:

$$t = \frac{\bar{X}-\mu_0}{S/\sqrt{n}} = \frac{Z}{\sqrt{\chi^2_{n-1}/(n-1)}} \sim t_{n-1}$$

where $Z\sim N(0,1)$ and $\chi^2_{n-1} = (n-1)S^2/\sigma^2$ are independent. The t-distribution has heavier tails than normal, accounting for extra uncertainty from estimating $\sigma$.

Worked Example

Problem: IQ test scores for n=16 students: $\bar{x}=106, s=12$. Test $H_0:\mu=100$ vs $H_1:\mu>100$ at $\alpha=0.05$.

$$t = \frac{106-100}{12/\sqrt{16}} = \frac{6}{3} = 2.00, \quad df=15$$

Critical value: $t_{15,0.05}=1.753$. Since $t=2.00>1.753$, reject $H_0$. p-value ≈ 0.032.

Hogg, McKean & Craig — Introduction to Mathematical Statistics, Ch. 4.4, 8.1
Casella & Berger — Statistical Inference, Ch. 8.3
§4 FAQ
§5 Misconceptions & Common Errors
❌ Misconception 1

"Use z-test when n > 30, t-test when n ≤ 30."
The rule is: use t-test when σ is UNKNOWN (almost always). The z-test requires known σ. For large n, t and z critical values are nearly identical (t_{∞}=z), but the correct test for unknown σ is always t-test regardless of n.
📖 Casella & Berger — Ch. 8.3

❌ Misconception 2

"The t-distribution is just a 'fatter normal distribution' — they're the same."
The t-distribution has heavier tails than normal, especially for small df. At df=1 (Cauchy distribution), the t has NO finite mean or variance — very different from normal. As df→∞, t→N(0,1). For df=5, P(|t|>3)=0.030 vs P(|Z|>3)=0.003 — tenfold difference in tail probability.
📖 Hogg, McKean & Craig — Ch. 4.4

❌ Error 1

Using n in denominator of sample variance instead of n-1
✅ The unbiased sample variance uses $S^2=\sum(X_i-\bar{X})^2/(n-1)$, not $/n$. Dividing by n gives the biased MLE estimator $\hat{\sigma}^2$. The t-test formula requires the unbiased $S$ with denominator $n-1$.
🔍 Confusing population variance formula (÷N) with sample variance (÷n-1).

❌ Error 2

Using wrong degrees of freedom (n instead of n-1)
✅ One degree of freedom is lost because $\bar{X}$ is estimated from the same data as $S$. Always use $df=n-1$ for the one-sample t-test. For two-sample independent t-test, df=n₁+n₂-2 (pooled) or Welch-Satterthwaite approximation.
🔍 Students look up t_{n} instead of t_{n-1} in tables.

❌ Error 3

Not checking normality assumption for very small samples
✅ The t-test assumes the population is normally distributed (especially important for n<10). For larger n, CLT makes it robust. For non-normal small samples, use the Wilcoxon signed-rank test (nonparametric alternative).
🔍 Students apply t-test to clearly non-normal data (e.g., highly skewed counts) with small n.

Casella & Berger — Statistical Inference, Ch. 8
Ross — A First Course in Probability, Ch. 6