Statistics

One-Sample T-Test

Last updated: March 2026 · Advanced
Before you start

You should be comfortable with:

Real-world applications
💊
Nursing

Medication dosages, IV drip rates, vital monitoring

The one-sample t-test is the workhorse of statistical testing. It tests claims about a population mean μ\mu when the population standard deviation σ\sigma is unknown — which is almost always. In practice, you rarely know σ\sigma with certainty. You have a sample, you compute the sample mean xˉ\bar{x} and sample standard deviation ss, and you need to decide whether the data provides evidence against a hypothesized value μ0\mu_0. The t-test handles this by using the t-distribution instead of the standard normal, accounting for the additional uncertainty introduced by estimating σ\sigma with ss. If you have worked through the introduction to hypothesis testing and the z-test, you already know the seven-step framework. Here you will apply it with the t-distribution.

When to Use the T-Test

Use a one-sample t-test when all of the following are true:

  • You are testing a claim about a single population mean μ\mu
  • The population standard deviation σ\sigma is unknown (you only have the sample standard deviation ss)
  • You have data from one sample, not from two groups or paired observations

If σ\sigma is known (rare), use a z-test instead. If you are comparing two groups, use a two-sample test. If you have paired data (before/after on the same subjects), use a paired t-test (also covered in the two-sample tests lesson).

The T-Test Statistic

The test statistic for a one-sample t-test is:

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

where:

  • xˉ\bar{x} = sample mean
  • μ0\mu_0 = hypothesized population mean (from H0H_0)
  • ss = sample standard deviation
  • nn = sample size
  • s/ns / \sqrt{n} = the estimated standard error of the mean

The test statistic follows a t-distribution with df=n1df = n - 1 degrees of freedom. Unlike the standard normal distribution (which is fully specified), the t-distribution requires knowing the degrees of freedom. With fewer degrees of freedom, the t-distribution has heavier tails — meaning you need a more extreme test statistic to achieve the same p-value. As dfdf increases, the t-distribution approaches the standard normal.

Conditions

Before performing a one-sample t-test, verify these conditions:

  1. Random sample — the data must come from a random sampling process or a randomized experiment
  2. Independence — individual observations must be independent (typically satisfied if the sample is less than 10% of the population)
  3. Nearly normal population OR large sample size — this condition depends on nn:
    • If nn is small (under 15): the population distribution should be approximately normal, with no outliers
    • If nn is moderate (15 to 30): mild skewness is acceptable, but there should be no strong outliers
    • If nn is large (30 or more): the Central Limit Theorem ensures the sampling distribution of xˉ\bar{x} is approximately normal, even if the population is skewed

Practical tip: Always plot your data. A histogram, dotplot, or boxplot of the sample can reveal outliers or extreme skewness that would violate the normality condition for small samples.

Worked Examples

Example 1: Two-Sided T-Test — Coffee Shop Cup Size

A coffee shop advertises that its large cups contain 16 oz. A skeptical customer measures the contents of 20 randomly selected large cups and finds xˉ=15.7\bar{x} = 15.7 oz with s=0.6s = 0.6 oz. Is there evidence the cups do not contain 16 oz? Test at α=0.05\alpha = 0.05.

Step 1: State the hypotheses.

H0:μ=16(cups contain 16 oz as advertised)H_0: \mu = 16 \quad \text{(cups contain 16 oz as advertised)}

Ha:μ16(cups do not contain 16 oz — two-sided)H_a: \mu \neq 16 \quad \text{(cups do not contain 16 oz — two-sided)}

Step 2: Choose significance level: α=0.05\alpha = 0.05.

Step 3: Check conditions. Random sample of 20 cups ✓. Independence (20 cups is a tiny fraction of all cups sold) ✓. Sample size is moderate (n=20n = 20), so we need to assume no strong outliers or extreme skew in cup volumes — reasonable for a manufacturing process ✓.

Step 4: Calculate the test statistic.

SE=sn=0.620=0.64.472=0.1342SE = \frac{s}{\sqrt{n}} = \frac{0.6}{\sqrt{20}} = \frac{0.6}{4.472} = 0.1342

t=15.7160.1342=0.30.1342=2.235t = \frac{15.7 - 16}{0.1342} = \frac{-0.3}{0.1342} = -2.235

Step 5: Find the p-value. With df=201=19df = 20 - 1 = 19 and a two-sided test:

p-value=2×P(t>2.235 with df=19)2×0.019=0.038\text{p-value} = 2 \times P(t > 2.235 \text{ with } df = 19) \approx 2 \times 0.019 = 0.038

Step 6: Make a decision. Since 0.038<0.050.038 < 0.05, we reject H0H_0.

Step 7: Conclusion in context. There is statistically significant evidence that the large cups do not contain 16 oz as advertised. The sample mean of 15.7 oz is significantly below 16 oz. The coffee shop appears to be under-pouring by about 0.3 oz on average. While this may seem small, it represents a consistent shortfall that could affect customer satisfaction — and potentially violate consumer protection standards.

Example 2: One-Sided T-Test — Hospital Discharge Time

Hospital protocol states that the average discharge process should take no more than 45 minutes. A hospital administrator studies a random sample of 30 patients and finds xˉ=48.3\bar{x} = 48.3 minutes with s=8.5s = 8.5 minutes. Is there evidence that the average discharge time exceeds 45 minutes? Test at α=0.05\alpha = 0.05.

Step 1: State the hypotheses.

H0:μ=45(discharge time is 45 minutes or less)H_0: \mu = 45 \quad \text{(discharge time is 45 minutes or less)}

Ha:μ>45(discharge time exceeds protocol — one-sided right)H_a: \mu > 45 \quad \text{(discharge time exceeds protocol — one-sided right)}

Step 2: Choose significance level: α=0.05\alpha = 0.05.

Step 3: Check conditions. Random sample ✓. Independence (30 patients from a large hospital population) ✓. Sample size n=30n = 30 is at the threshold for the CLT ✓.

Step 4: Calculate the test statistic.

SE=sn=8.530=8.55.477=1.552SE = \frac{s}{\sqrt{n}} = \frac{8.5}{\sqrt{30}} = \frac{8.5}{5.477} = 1.552

t=48.3451.552=3.31.552=2.126t = \frac{48.3 - 45}{1.552} = \frac{3.3}{1.552} = 2.126

Step 5: Find the p-value. With df=29df = 29 and a one-sided right test:

p-value=P(t>2.126 with df=29)0.021\text{p-value} = P(t > 2.126 \text{ with } df = 29) \approx 0.021

Step 6: Make a decision. Since 0.021<0.050.021 < 0.05, we reject H0H_0.

Step 7: Conclusion in context. There is statistically significant evidence that the average discharge time exceeds the 45-minute protocol. The observed mean of 48.3 minutes is significantly longer than the target. The hospital should investigate bottlenecks in the discharge process — common causes include delayed paperwork, waiting for prescriptions, and scheduling follow-up appointments.

Reading T-Test Output

When you use a calculator or software (TI-84, Excel, R, Python, etc.) to perform a t-test, the output typically includes:

  • t-statistic — the calculated value of t=xˉμ0s/nt = \frac{\bar{x} - \mu_0}{s/\sqrt{n}}
  • df — degrees of freedom (n1n - 1)
  • p-value — the probability used for the decision. Make sure you know whether the software reports a one-sided or two-sided p-value. Some software always reports two-sided; if you need one-sided, divide by 2.
  • Sample mean xˉ\bar{x} — the observed mean
  • Confidence interval — many programs also report a confidence interval for μ\mu, which provides the same information in a different form

Example software output:

StatisticValue
t-2.235
df19
p-value (two-sided)0.038
Sample mean15.7
95% CI(15.42, 15.98)

Reading this: the test statistic is 2.235-2.235, with 19 degrees of freedom. The two-sided p-value is 0.038, which is less than 0.05, so we reject the null hypothesis. The 95% confidence interval does not contain 16, which is consistent with the rejection decision.

T-Test vs Z-Test — When to Use Which

FeatureZ-TestT-Test
Use whenσ\sigma is knownσ\sigma is unknown (use ss)
How commonRare in practiceVery common — the default choice
Reference distributionStandard normal (ZZ)t-distribution with df=n1df = n - 1
Test statisticz=xˉμ0σ/nz = \frac{\bar{x} - \mu_0}{\sigma/\sqrt{n}}t=xˉμ0s/nt = \frac{\bar{x} - \mu_0}{s/\sqrt{n}}
Critical valuesSame for all sample sizesDepend on degrees of freedom
For large nnResults are virtually identical to the t-testApproaches the z-test as dfdf \to \infty
Typical scenarioKnown manufacturing σ\sigma, textbook problemsAny real data set where σ\sigma must be estimated

Bottom line: When in doubt, use the t-test. If σ\sigma happens to be known and you use a z-test, that is fine. But if σ\sigma is unknown and you use a z-test anyway (substituting ss for σ\sigma), your p-values will be slightly too small for small samples — the t-test correctly accounts for this additional uncertainty.

Confidence Interval Connection

There is a deep link between hypothesis tests and confidence intervals. A two-sided hypothesis test at significance level α\alpha is equivalent to checking whether the corresponding (1α)×100%(1-\alpha) \times 100\% confidence interval for μ\mu contains the null value μ0\mu_0.

  • If μ0\mu_0 falls inside the confidence interval: fail to reject H0H_0
  • If μ0\mu_0 falls outside the confidence interval: reject H0H_0

Example: In Example 1 above, we rejected H0:μ=16H_0: \mu = 16 at α=0.05\alpha = 0.05. The 95% confidence interval for μ\mu is:

xˉ±tsn=15.7±2.093×0.1342=15.7±0.281=(15.42,15.98)\bar{x} \pm t^* \cdot \frac{s}{\sqrt{n}} = 15.7 \pm 2.093 \times 0.1342 = 15.7 \pm 0.281 = (15.42, 15.98)

Since 16 is not in the interval (15.42,15.98)(15.42, 15.98), we reject H0H_0 — consistent with the hypothesis test result. The confidence interval gives additional information: not only is the mean significantly different from 16, but our best estimate of the true mean is somewhere between 15.42 and 15.98 oz.

This duality is especially useful for communicating results. Instead of saying “we rejected the null hypothesis with p = 0.038,” you can say “we are 95% confident the true mean is between 15.42 and 15.98 oz, which does not include the advertised 16 oz.”

Real-World Application: Nursing — Testing Average Recovery Time

A surgical unit adopts a new post-operative care protocol. The established average recovery time under the old protocol was 5.2 days. The head nurse wants to know whether the new protocol has changed recovery time. A random sample of 18 patients under the new protocol yields xˉ=4.6\bar{x} = 4.6 days and s=1.1s = 1.1 days. Test at α=0.05\alpha = 0.05.

H0:μ=5.2Ha:μ5.2H_0: \mu = 5.2 \quad H_a: \mu \neq 5.2

Check conditions: random sample ✓, independence ✓, n=18n = 18 is moderate so we need approximate normality — recovery times are typically right-skewed, but mild skew is acceptable for n=18n = 18 ✓.

SE=1.118=1.14.243=0.2593SE = \frac{1.1}{\sqrt{18}} = \frac{1.1}{4.243} = 0.2593

t=4.65.20.2593=0.60.2593=2.314t = \frac{4.6 - 5.2}{0.2593} = \frac{-0.6}{0.2593} = -2.314

With df=17df = 17, the two-sided p-value: 2×P(t>2.314,df=17)2×0.017=0.0342 \times P(t > 2.314, df = 17) \approx 2 \times 0.017 = 0.034.

Since 0.034<0.050.034 < 0.05, reject H0H_0. There is evidence that the new protocol has changed recovery time. The sample mean of 4.6 days is significantly lower than the historical 5.2 days — a reduction of 0.6 days per patient that is both statistically significant and clinically meaningful. Shorter recovery times translate directly to improved patient well-being, faster bed turnover, and reduced hospital costs.

Practice Problems

Test your understanding with these problems. Click to reveal each answer.

Problem 1: A food company labels its soup cans as containing 305 grams. A consumer group measures 25 randomly selected cans and finds xˉ=301\bar{x} = 301 g with s=8s = 8 g. Is there evidence the cans contain less than 305 g? (α=0.05\alpha = 0.05)

H0:μ=305H_0: \mu = 305, Ha:μ<305H_a: \mu < 305 (one-sided left)

SE=825=85=1.6SE = \frac{8}{\sqrt{25}} = \frac{8}{5} = 1.6

t=3013051.6=41.6=2.500t = \frac{301 - 305}{1.6} = \frac{-4}{1.6} = -2.500

With df=24df = 24, P(t<2.500)0.010P(t < -2.500) \approx 0.010.

Since 0.010<0.050.010 < 0.05, reject H0H_0.

Answer: There is statistically significant evidence that the cans contain less than 305 grams. The sample mean of 301 g is significantly below the label claim.

Problem 2: A teacher claims the average score on a standardized test at her school is 500. A random sample of 32 students yields xˉ=512\bar{x} = 512 and s=45s = 45. Test whether the mean score differs from 500 at α=0.05\alpha = 0.05.

H0:μ=500H_0: \mu = 500, Ha:μ500H_a: \mu \neq 500 (two-sided)

SE=4532=455.657=7.955SE = \frac{45}{\sqrt{32}} = \frac{45}{5.657} = 7.955

t=5125007.955=127.955=1.508t = \frac{512 - 500}{7.955} = \frac{12}{7.955} = 1.508

With df=31df = 31, two-sided p-value =2×P(t>1.508)2×0.071=0.142= 2 \times P(t > 1.508) \approx 2 \times 0.071 = 0.142.

Since 0.142>0.050.142 > 0.05, fail to reject H0H_0.

Answer: There is not sufficient evidence to conclude the mean score differs from 500. The observed difference of 12 points above 500 could reasonably occur by chance.

Problem 3: A fitness trainer claims her program increases resting heart rate recovery to below 72 bpm. She measures 15 clients after 8 weeks: xˉ=69.5\bar{x} = 69.5 bpm, s=5.2s = 5.2 bpm. Test at α=0.05\alpha = 0.05 (one-sided).

H0:μ=72H_0: \mu = 72, Ha:μ<72H_a: \mu < 72 (one-sided left)

SE=5.215=5.23.873=1.343SE = \frac{5.2}{\sqrt{15}} = \frac{5.2}{3.873} = 1.343

t=69.5721.343=2.51.343=1.862t = \frac{69.5 - 72}{1.343} = \frac{-2.5}{1.343} = -1.862

With df=14df = 14, P(t<1.862)0.042P(t < -1.862) \approx 0.042.

Since 0.042<0.050.042 < 0.05, reject H0H_0.

Answer: There is statistically significant evidence that the program reduces resting heart rate below 72 bpm. The sample mean of 69.5 bpm is significantly lower than the threshold.

Problem 4: The recommended daily water intake is 2,000 mL. A dietitian surveys 40 office workers and finds xˉ=1,850\bar{x} = 1{,}850 mL with s=350s = 350 mL. Is there evidence that office workers drink less than the recommended amount? (α=0.01\alpha = 0.01)

H0:μ=2000H_0: \mu = 2000, Ha:μ<2000H_a: \mu < 2000 (one-sided left)

SE=35040=3506.325=55.34SE = \frac{350}{\sqrt{40}} = \frac{350}{6.325} = 55.34

t=1850200055.34=15055.34=2.711t = \frac{1850 - 2000}{55.34} = \frac{-150}{55.34} = -2.711

With df=39df = 39, P(t<2.711)0.005P(t < -2.711) \approx 0.005.

Since 0.005<0.010.005 < 0.01, reject H0H_0.

Answer: There is statistically significant evidence at the 1% level that office workers drink less than the recommended 2,000 mL per day. The average of 1,850 mL represents a meaningful shortfall of 150 mL.

Problem 5: A bakery says its loaves weigh 680 g on average. An inspector weighs 10 random loaves: xˉ=673\bar{x} = 673 g, s=12s = 12 g. Test whether the mean weight differs from 680 g at α=0.05\alpha = 0.05. (Note: with n=10n = 10, you need the normality assumption.)

H0:μ=680H_0: \mu = 680, Ha:μ680H_a: \mu \neq 680 (two-sided)

SE=1210=123.162=3.795SE = \frac{12}{\sqrt{10}} = \frac{12}{3.162} = 3.795

t=6736803.795=73.795=1.845t = \frac{673 - 680}{3.795} = \frac{-7}{3.795} = -1.845

With df=9df = 9, two-sided p-value =2×P(t>1.845)2×0.049=0.098= 2 \times P(t > 1.845) \approx 2 \times 0.049 = 0.098.

Since 0.098>0.050.098 > 0.05, fail to reject H0H_0.

Answer: There is not sufficient evidence to conclude the mean loaf weight differs from 680 g. The sample of 10 is small, and while the observed mean is 7 g below the target, this difference is not statistically significant. A larger sample would provide more power to detect such a difference.

Key Takeaways

  • The one-sample t-test is the standard test for a population mean when σ\sigma is unknown — which is nearly all real-world situations
  • The test statistic is t=xˉμ0s/nt = \frac{\bar{x} - \mu_0}{s / \sqrt{n}} with df=n1df = n - 1 degrees of freedom
  • The t-distribution has heavier tails than the standard normal, producing wider intervals and larger p-values for small samples — this correctly accounts for the uncertainty in estimating σ\sigma with ss
  • For large nn (30 or more), the t-test and z-test give nearly identical results because the t-distribution approaches the normal
  • Check conditions carefully, especially for small samples: the data should be approximately normal with no strong outliers
  • A two-sided t-test at level α\alpha and a (1α)×100%(1-\alpha) \times 100\% confidence interval always agree: reject H0H_0 if and only if μ0\mu_0 is outside the confidence interval
  • Report both the p-value and a confidence interval whenever possible — the CI communicates the direction and magnitude of the effect, not just whether it is significant
  • In clinical and healthcare settings, the t-test is essential for evaluating protocols, treatment outcomes, and quality benchmarks with real patient data

Return to Statistics for more topics in this section.

Last updated: March 29, 2026