The One-Sample t-Test

The One-Sample t-Test

Question: Is there a significant difference between the mean of your sample and a known benchmark?

Use it when: You have one group and want to compare its mean to a fixed value.

Hypotheses:

  • H0H_0: The sample mean equals the benchmark.
  • H1H_1: The sample mean differs from the benchmark.


Test statistic:

t=xˉμs/nt = \frac{\bar{x} - \mu}{s/\sqrt{n}}

where xˉ\bar{x} is the sample mean, mumu is the benchmark, ss is the sample standard deviation, and nn is the sample size.

In Python: scipy.stats.ttest_1samp(sample, popmean=benchmark)

One-Sample t-Test
Choose a scenario
Adjust inputs
Sample mean (x̄)4.7
Std dev (s)0.3
Sample size (n)100
Benchmark (μ₀)4.5
t-Distribution (df = 99)
t−t-4-3-2-101234t (df = 99)

Shaded tails = p-value region. Orange marker = t-statistic.

Results
Standard error
0.0300
t-statistic
6.667
Degrees of freedom
99
p-value (two-tailed)
< 0.001
Interpretation (α = 0.05)

p = < 0.001 < 0.05 — reject H₀. The sample mean (4.7) differs significantly from the benchmark (4.5).

Step-by-step
1. SE = s / √n = 0.3 / √100 = 0.0300
2. t = (x̄ − μ₀) / SE = (4.74.5) / 0.0300 = 6.667
3. df = n − 1 = 100 − 1 = 99
4. p = < 0.001 (significant at α = 0.05)
p-value region (shaded tails)t = observed t-statistic−t = mirror (two-tailed)

Enter sample statistics (mean, SD, n). Compute the t-statistic and p-value, and see where the statistic falls on the t-distribution.