Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

This week in a line: you’ll build a confidence interval and run a hypothesis test for a single population mean, using the t-distribution.

It’s a holiday-shortened week, so campus is quieter than usual, but your two biggest new statistics tools of the semester are due right on schedule. Last week you built a confidence interval and ran a hypothesis test for a single proportion — a fraction of people who do something. This week asks the parallel question about an average instead: how long does a typical nap last between classes? Is the average commute to campus really as short as the parking office claims? Both questions need the same two moves you already know — a confidence interval, then a hypothesis test — but for a mean, those moves lean on a new reference distribution, because you almost never know the population’s true spread.

1The t-distribution: the price of not knowing σ\sigma

Back in Week 9, the standard error of a sample mean was SExˉ=σ/nSE_{\bar x} = \sigma/\sqrt{n}, where σ\sigma (population standard deviation) was simply given. In real problems, you almost never know σ\sigma — all you have is your sample’s standard deviation, ss. Swapping in ss for σ\sigma seems harmless, but it adds a second layer of guessing on top of sampling variability: ss itself bounces around from sample to sample, especially when nn is small. To account for that extra wobble, one-mean inference uses the t-distribution instead of the Normal (z) distribution whenever σ\sigma is unknown — which is the normal state of affairs.

The t-distribution is bell-shaped and centered at 0, just like z, but it is flatter in the middle and has heavier tails — more area out past ±2\pm 2 or ±3\pm 3 — to cover the extra uncertainty from estimating σ\sigma with ss. Exactly how heavy the tails are depends on the degrees of freedom, df=n−1df = n - 1: fewer degrees of freedom (smaller samples) means heavier tails and a wider critical value; as nn grows, dfdf grows, and the t-curve tightens until it is nearly indistinguishable from z. Running R’s qt() across a range of dfdf makes the convergence concrete:

dfdf510203050100
t∗t^* (95% CI)2.5712.2282.0862.0422.0091.984

For comparison, the Normal critical value is a fixed z∗=1.960z^* = 1.960 for a 95% interval. Notice how t∗t^* starts well above z∗z^* at df=5df = 5 and steadily closes the gap — by df=100df = 100 it is only 0.024 away from 1.960, and it would keep sliding closer as dfdf grows further. That single row of numbers is the large-sample story of this course: t and z agree closely once your sample is reasonably large, but t is the honest choice whenever σ\sigma is estimated rather than known.

Figure 1. A t-distribution curve overlaid on a standard Normal curve, both centered at 0 and bell-shaped, shows the t-curve sitting slightly lower at the peak and slightly higher than the Normal curve out past ±2\pm 2 on both sides — the “heavier tails” that make t∗t^* larger than z∗z^* for the same confidence level.

A t-distribution curve (df = 23) overlaid on a standard Normal curve, both centered at 0 and bell-shaped. The t-curve sits slightly lower at the peak and slightly higher than the Normal curve out past plus-or-minus 2 on both sides, showing the heavier tails that make t-star larger than z-star for the same confidence level.

2A confidence interval for a mean

Conditions first. Before building an interval, check: (1) independence — observations come from a random sample or a random process, so one value doesn’t influence another; (2) large sample or nearly normal — with n≥30n \geq 30 the Central Limit Theorem covers you even if the data are somewhat skewed; with smaller nn, the sample should show no strong skew and no extreme outliers.

With those conditions met, the confidence interval for a population mean μ\mu is

xˉ±t∗⋅sn\bar{x} \pm t^* \cdot \frac{s}{\sqrt{n}}

where xˉ\bar{x} is the sample mean, ss is the sample standard deviation, nn is the sample size, s/ns/\sqrt{n} is the standard error of the mean, and t∗t^* is the critical value cut from the t-distribution with df=n−1df = n-1 degrees of freedom at the chosen confidence level.

Figure 2. A number line from 15 to 35 minutes marking the sample mean xˉ=25.5\bar x=25.5 with a dot and a horizontal bracket spanning from 20.33 to 30.67, representing the 95% confidence interval for the true mean nap length.

A number line from 15 to 35 minutes marking the sample mean x-bar equals 25.5 with a dot and a horizontal bracket spanning from 20.33 to 30.67, the 95 percent confidence interval for the true mean nap length.

Figure 3. A histogram of the 24 nap lengths is mounded between about 10 and 35 minutes with a thin tail stretching out to 51 and 57 minutes — a mild right skew, consistent with the mean (25.5 minutes) sitting a bit above the median (22.5 minutes) and with the single flagged outlier at 57.

A histogram of the 24 nap lengths, mounded between about 10 and 35 minutes with a thin tail stretching out to 51 and 57 minutes, a mild right skew. A dashed line marks the mean at 25.5 minutes and a dotted line marks the median at 22.5 minutes, with the single flagged outlier visible at 57.

3The one-sample t-test for a mean

A hypothesis test for a mean checks a claim about μ\mu using the same ingredients. The null hypothesis states a specific value, H0:μ=μ0H_0: \mu = \mu_0; the alternative HaH_a says μ\mu differs from μ0\mu_0 (two-sided) or is specifically greater than or less than it (one-sided). The test statistic is

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

and the p-value is the area under the t-curve with df=n−1df = n-1 degrees of freedom, out past the observed tt in the direction(s) HaH_a points. As always: small p-value (below your significance level α\alpha) means the data are surprising under H0H_0, so you reject H0H_0; otherwise you fail to reject H0H_0.

Large samples: why t and z nearly agree. Re-running Example 2’s exact summary statistics through the z-based equivalent (same xˉ\bar x, ss, and nn, but referenced against the Normal curve instead of t44t_{44}) gives z=2.49z = 2.49 — the identical test statistic value, because the formula is the same — with p=0.0064p = 0.0064, versus the t-test’s p=0.0083p = 0.0083. The two p-values are close enough that both lead to the same decision at α=0.05\alpha = 0.05, exactly the pattern the t∗t^*-vs-z∗z^* table above predicted: once nn is large (here df=44df = 44), the extra uncertainty from estimating σ\sigma with ss barely matters, and t and z tell the same story. For small samples, they can disagree more, which is why this course leads with t.

See it in R.

suppressMessages({library(mosaic); library(BSDA)})

# Worked Example 1: nap length, confidence interval from raw data
nap_minutes_sim <- c(20, 51, 18, 38, 35, 9, 28, 34, 10, 22, 19, 35,
                      10, 24, 9, 57, 21, 32, 23, 18, 32, 21, 26, 20)
naps <- data.frame(nap_minutes_sim)
favstats(~ nap_minutes_sim, data = naps)
t.test(~ nap_minutes_sim, data = naps, conf.level = 0.95)$conf.int

# Worked Example 2: commute time, one-sample t-test from summary stats (BSDA)
tsum.test(mean.x = 23.49, s.x = 9.39, n.x = 45, mu = 20, alternative = "greater")

# large-sample z equivalent, same summary stats (noted, not required)
zsum.test(mean.x = 23.49, sigma.x = 9.39, n.x = 45, mu = 20, alternative = "greater")

t.test()$conf.int returns 20.33286 30.66714, matching Example 1’s hand-built interval. tsum.test() returns t = 2.4933, df = 44, p-value = 0.008246, matching Example 2. zsum.test() on the identical summary numbers returns z = 2.4933, p-value = 0.006329 — the same test statistic, a slightly smaller p-value, and the same decision at α=0.05\alpha = 0.05, exactly the t-vs-z agreement described above. Use tsum.test()/zsum.test() whenever a problem only gives you xˉ\bar{x}, ss (or σ\sigma), and nn rather than a raw data list.

4Check your understanding

  1. A campus wellness survey plans to estimate mean daily screen time from a random sample of n=18n = 18 students. The sample’s histogram shows one clear peak, roughly symmetric shape, and no outliers. Is it reasonable to use t-procedures here? Explain using both conditions from this week (independence, and sample size/shape).

  2. A sample of n=36n = 36 receipts at a campus café gives xˉ=$6.40\bar{x} = \$6.40 and s=$1.80s = \$1.80. Find the standard error of the mean. (Do not build the full interval yet — just the standard error.)

  3. A sample of n=16n = 16 phone battery-life tests gives xˉ=8.2\bar{x} = 8.2 hours and s=1.6s = 1.6 hours. Construct and interpret a 90% confidence interval for the true mean battery life.

  4. Using the t-table row for df=23df = 23 from this week’s skills refresher, what is t∗t^* for a 99% confidence interval? How does it compare to the 95% value used in Worked Example 1, and why does a higher confidence level need a larger t∗t^*?

  5. A streaming service claims subscribers watch an average of 90 minutes per day. A random sample of n=20n = 20 subscribers gives xˉ=97\bar{x} = 97 minutes and s=15s = 15 minutes. Test H0:μ=90H_0: \mu = 90 vs. Ha:μ>90H_a: \mu > 90 at α=0.05\alpha = 0.05, showing the test statistic, dfdf, p-value, decision, and a one-sentence conclusion in context.

  6. Explain, in your own words, why t∗t^* is larger than z∗z^* for the same confidence level when nn is small, and why that gap shrinks as nn grows. Use the dfdf-vs-t∗t^* table from this week to support your answer.

5Key terms