Unit 6, lesson 45

One-Sample t-Tests

How the one-sample t test compares a sample mean with a fixed benchmark using the t statistic and n minus 1 degrees of freedom, what the standardized mean difference adds, and how the test matches a confidence interval.

  • Video 45
  • Tests for Means and Proportions

A service team has a target mean visit duration of 22 minutes, fixed before any data were collected. A sample of 25 independently measured visits averages 24 minutes with a sample standard deviation of 5 minutes. Two minutes above the target could reflect a real shift in the population mean or only the ordinary variation of a sample mean, and the population standard deviation is unknown. This lesson builds the one-sample t test for that question, separates the size of the difference from the strength of the evidence, and shows how the test and the matching confidence interval answer the same question.

Key terms

One-sample t test

Definition Let x1,…,xnx_1, \dots, x_n, with n≥2n \ge 2, be observations from a population with mean μ\mu, and let μ0\mu_0 be a benchmark fixed without using these observations. The one-sample t test tests H0:μ=μ0H_0: \mu = \mu_0 against an alternative chosen before the data are seen, either the two-sided H1:μ≠μ0H_1: \mu \ne \mu_0 or one of the one-sided H1:μ>μ0H_1: \mu > \mu_0 and H1:μ<μ0H_1: \mu < \mu_0. It computes the t statistic tt of the next card and, with Tn−1T_{n-1} a random variable having the t distribution with n−1n - 1 degrees of freedom, reports the p-value for the chosen alternative.

Alternativep-value
H1:μ≠μ0H_1: \mu \ne \mu_0P(∣Tn−1∣≥∣t∣)P(\lvert T_{n-1} \rvert \ge \lvert t \rvert)
H1:μ>μ0H_1: \mu > \mu_0P(Tn−1≥t)P(T_{n-1} \ge t)
H1:μ<μ0H_1: \mu < \mu_0P(Tn−1≤t)P(T_{n-1} \le t)

These p-values are exact when the observations are independent draws from a normal population. For independent draws from other populations they are approximations, whose quality the card on conditions discusses.

In plain words The test asks whether the sample mean sits farther from the benchmark than the sampling variation of a mean would ordinarily produce, with that variation estimated from the same sample. The alternative is part of the question, so it is chosen in advance.

Example For the visits, n=25n = 25, xˉ=24\bar{x} = 24 minutes, s=5s = 5 minutes and μ0=22\mu_0 = 22 minutes, and the next card finds t=2t = 2 with 2424 degrees of freedom. With the two-sided alternative the p-value is P(∣T24∣≥2)≈0.0569P(\lvert T_{24} \rvert \ge 2) \approx 0.0569, so a test at α=0.05\alpha = 0.05 does not reject. That does not show that μ=22\mu = 22, since the data are also compatible with means a few minutes above it. Had the question fixed in advance been whether μ>22\mu > 22, the p-value would be the upper tail P(T24≥2)≈0.0285P(T_{24} \ge 2) \approx 0.0285, and the test at 0.050.05 would reject. The lower alternative μ<22\mu < 22 would give P(T24≤2)≈0.9715P(T_{24} \le 2) \approx 0.9715. These numbers answer three different questions, and choosing the smallest after seeing the data is not a valid test.

t statistic

Definition For a sample of size n≥2n \ge 2 with mean xˉ\bar{x} and sample standard deviation s>0s > 0, computed with the n−1n - 1 denominator, the t statistic for the benchmark μ0\mu_0 is

t=xˉ−μ0s/n,t = \frac{\bar{x} - \mu_0}{s / \sqrt{n}},

where s/ns/\sqrt{n} is the estimated standard error of the sample mean. If the observations are independent draws from N(μ0,σ2)N(\mu_0, \sigma^2) with σ>0\sigma > 0, the statistic, viewed as a random variable, has the t distribution with n−1n - 1 degrees of freedom, written tn−1t_{n-1}. This distribution is symmetric about 00, has heavier tails than N(0,1)N(0, 1) for every finite number of degrees of freedom, and approaches N(0,1)N(0, 1) as the degrees of freedom grow. The count is n−1n - 1 because the deviations xi−xˉx_i - \bar{x} always sum to zero, so the standard deviation rests on only n−1n - 1 freely varying deviations.

In plain words The t statistic counts how many estimated standard errors separate the sample mean from the benchmark. Because the denominator is estimated from the same sample, the statistic varies more than it would with a known σ\sigma, and the heavier tails of the t distribution account for that extra variation.

Example For the visits,

SE⁡=sn=525=1 min,t=24−221=2,\begin{aligned} \operatorname{SE} &= \frac{s}{\sqrt{n}} = \frac{5}{\sqrt{25}} \\[0.4em] &= 1 \text{ min}, \\[0.4em] t &= \frac{24 - 22}{1} = 2, \end{aligned}

with 25−1=2425 - 1 = 24 degrees of freedom. The 55 minutes describe how much individual visits vary, and the 11 minute describes how much the mean of 2525 visits varies from sample to sample. Reading t=2t = 2 against N(0,1)N(0, 1) instead of t24t_{24} would give the two-sided p-value 0.04550.0455 instead of 0.05690.0569 and would reject at 0.050.05, a conclusion that ignores the uncertainty in ss. The matching critical values are 1.9601.960 for the normal distribution and about 2.0642.064 for t24t_{24}.

Conditions for the one-sample t test

Definition The p-values of the one-sample t test are exact when three conditions hold. The observations are independent, they come from a single normal population with unknown standard deviation σ>0\sigma > 0, and μ0\mu_0 is a fixed number chosen without using the sample. Without normality the test is approximate. For independent observations from one population with finite positive variance, the distribution of the t statistic under H0H_0 approaches N(0,1)N(0, 1) as nn grows, and so does tn−1t_{n-1}, so the p-values become accurate for large enough samples. How large depends on the population, and strong skewness or heavy tails call for larger samples, especially for one-sided tests. Independence, and the link between the sample and the population it is meant to describe, come from how the data were collected.

In plain words The normal model matters most when the sample is small, and a plot of the data can reveal skewness or outliers that make it doubtful. No plot can show that the observations are independent or that they represent the population of interest. The benchmark must be a fixed target, not another estimate with its own uncertainty.

Example Suppose the 2525 visit records came from 55 customers with 55 visits each, and visits by the same customer tend to have similar durations. The records are then not 2525 independent observations, and s/25s/\sqrt{25} understates the uncertainty of the mean. If the customers were sampled independently, one analysis that respects the dependence uses the 55 customer means as the observations, with 44 degrees of freedom. If instead the 2222 minutes were the mean of an earlier sample of visits, the question would compare two estimates and would call for a two-sample comparison.

Standardized mean difference

Definition For a one-sample comparison with benchmark μ0\mu_0, the standardized mean difference is

d=xˉ−μ0s,d = \frac{\bar{x} - \mu_0}{s},

the difference between the sample mean and the benchmark in units of the sample standard deviation of individual observations. It estimates the population quantity (μ−μ0)/σ(\mu - \mu_0)/\sigma. It has no units, its sign gives the direction of the difference, and it is related to the t statistic by

t=dn.t = d\sqrt{n} .

Because dd estimates a fixed population quantity, more data make it more precise rather than larger, while ∣t∣\lvert t \rvert tends to grow like n\sqrt{n} whenever μ≠μ0\mu \ne \mu_0.

In plain words The t statistic measures how clearly the data separate the mean from the benchmark, and the standardized difference measures how big the gap is compared with the spread of individual values. Report the raw difference in its original units as well, because whether a gap matters depends on the setting, not on a universal scale.

Example For the visits, d=(24−22)/5=0.4d = (24 - 22)/5 = 0.4, so the sample mean lies 0.40.4 standard deviations of individual visits above the target, and t=0.4×25=2t = 0.4 \times \sqrt{25} = 2. The raw difference is 22 minutes. Whether a 22-minute delay is important depends on the service, for example on how long customers wait or how many visits fit into a day, and neither dd nor tt can decide that.

Duality of tests and confidence intervals

Definition For a level α\alpha with 0<α<10 < \alpha < 1, the two-sided 100(1−α)100(1 - \alpha) percent t interval for μ\mu is

xˉ±t1−α/2, n−1 sn,\bar{x} \pm t_{1-\alpha/2,\,n-1} \, \frac{s}{\sqrt{n}},

where t1−α/2, n−1t_{1-\alpha/2,\,n-1} is the 1−α/21 - \alpha/2 quantile of the t distribution with n−1n - 1 degrees of freedom. For every benchmark μ0\mu_0, the two-sided one-sample t test of H0:μ=μ0H_0: \mu = \mu_0 on the same data has p>αp > \alpha exactly when μ0\mu_0 lies strictly inside this interval, p=αp = \alpha exactly when μ0\mu_0 is an endpoint, and p<αp < \alpha exactly when μ0\mu_0 lies outside. The interval is therefore the set of benchmarks that the test at level α\alpha does not reject, apart from the two endpoints, where the decision depends on the rule for p=αp = \alpha. The match needs the same data, model, standard error, degrees of freedom, level and sidedness. A one-sided test against μ>μ0\mu > \mu_0 at level α\alpha matches the one-sided lower confidence bound xˉ−t1−α, n−1 s/n\bar{x} - t_{1-\alpha,\,n-1}\, s/\sqrt{n} instead.

In plain words Apart from its two endpoints, a confidence interval lists the benchmarks that the matching test would not reject, so one calculation answers both whether a particular value is compatible with the data and which values are. The interval also shows the whole range of means compatible with the data under this procedure, which a p-value alone does not.

Example With t0.975, 24≈2.0639t_{0.975,\,24} \approx 2.0639 and a standard error of 11 minute, the 9595 percent interval is

24±2.0639×1≈[21.936, 26.064] min.\begin{gathered} 24 \pm 2.0639 \times 1 \\[0.4em] \approx [21.936,\ 26.064] \text{ min}. \end{gathered}

The benchmark 2222 lies inside, matching p≈0.0569>0.05p \approx 0.0569 > 0.05. A benchmark of 21.521.5 minutes lies outside, and its test gives t=2.5t = 2.5 and p≈0.0197p \approx 0.0197. The interval estimates the population mean, so it is not a range meant to hold 9595 percent of individual visit times. The 9595 percent describes how often the procedure captures μ\mu over repeated samples, not a probability that this particular interval contains it.

Check yourself

  1. A second sample of 1616 independent observations has mean 1818 and sample standard deviation 44, and the fixed benchmark is 2020. Assuming the conditions hold, find the standard error, the t statistic, its degrees of freedom and the standardized mean difference. Then use t0.975, 15≈2.1314t_{0.975,\,15} \approx 2.1314 to decide whether the two-sided test at the 55 percent level rejects, and find the matching interval.
Show the answer

The standard error is 4/16=14/\sqrt{16} = 1, so

t=18−201=−2t = \frac{18 - 20}{1} = -2

with 16−1=1516 - 1 = 15 degrees of freedom, and the standardized mean difference is d=−2/4=−0.5d = -2/4 = -0.5. Since ∣t∣=2<2.1314\lvert t \rvert = 2 < 2.1314, the two-sided test at the 55 percent level does not reject, and software gives the p-value 2P(T15≥2)≈0.06392P(T_{15} \ge 2) \approx 0.0639. The matching interval is 18±2.1314≈[15.869, 20.131]18 \pm 2.1314 \approx [15.869,\ 20.131], which contains 2020, as duality requires. The negative sign says the sample mean is below the benchmark, while the two-sided p-value uses only the size of tt. Not rejecting does not show that μ=20\mu = 20, because the interval also contains means as low as about 15.915.9.

  1. Suppose the visit study had measured 100100 independent visits with the same mean of 2424 minutes and the same standard deviation of 55 minutes. Find the t statistic and the standardized mean difference and compare them with the sample of 2525. Software gives the two-sided p-value 0.000120.00012.
Show the answer

The standard error is 5/100=0.55/\sqrt{100} = 0.5 minutes, so t=2/0.5=4t = 2/0.5 = 4 with 9999 degrees of freedom, while d=2/5=0.4d = 2/5 = 0.4 is unchanged. The relation t=dnt = d\sqrt{n} gives 0.4×10=40.4 \times 10 = 4. The larger sample locates the mean more precisely, and the 9595 percent interval narrows to about 24±1.9842×0.5≈[23.008, 24.992]24 \pm 1.9842 \times 0.5 \approx [23.008,\ 24.992] minutes. The evidence against μ=22\mu = 22 is much stronger, but the estimated difference is the same 22 minutes. A smaller p-value does not make the delay larger or more important.

  1. Before collecting the 2525 visits, the team planned a one-sided test of H0:μ=22H_0: \mu = 22 against H1:μ>22H_1: \mu > 22 at α=0.05\alpha = 0.05. The p-value 0.02850.0285 leads to rejection, yet the two-sided 9595 percent interval [21.936, 26.064][21.936,\ 26.064] contains 2222. A colleague calls this a contradiction. Resolve it, using t0.95, 24≈1.7109t_{0.95,\,24} \approx 1.7109.
Show the answer

There is no contradiction, because the two procedures answer different questions. The one-sided test at α=0.05\alpha = 0.05 matches the one-sided 9595 percent lower confidence bound

24−1.7109×1≈22.289 min,\begin{aligned} &24 - 1.7109 \times 1 \\[0.4em] &\quad \approx 22.289 \text{ min}, \end{aligned}

and 2222 lies below it, in agreement with the rejection. The two-sided 9595 percent interval matches the two-sided test at 0.050.05, whose p-value 0.05690.0569 does not lead to rejection. The bound 22.28922.289 is also the lower end of the two-sided 9090 percent interval. The one-sided analysis is legitimate only because its direction was fixed before the data were seen.

How this lesson connects