How to run a one-sample t-test

A one-sample t-test compares the mean of a single sample to a hypothesized population mean. It applies when the population standard deviation is unknown and the sample is drawn from a normally distributed population or the sample size is sufficiently large (n30n \ge 30).

The setup

Define the null hypothesis (H0:μ=μ0H_0: \mu = \mu_0) and the alternative hypothesis (Ha:μeqμ0H_a: \mu eq \mu_0, <μ0< \mu_0, or >μ0> \mu_0). Choose a significance level, typically α=0.05\alpha = 0.05. Identify the sample size (nn), sample mean (xˉ\bar{x}), and sample standard deviation (ss).

The steps

  1. Compute the test statistic: t=xˉμ0s/nt = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}. 2. Determine the degrees of freedom: df=n1df = n - 1. 3. Find the p-value or critical t-value using a t-distribution table. 4. Compare the test statistic to the critical value. 5. Reject H0H_0 if the p-value <α< \alpha or if the test statistic falls in the rejection region.

Checking the result

Verify that the sample data does not contain severe outliers using a boxplot. Ensure the sample size justifies the assumption of normality via the Central Limit Theorem if the underlying distribution is not perfectly normal.

Common errors

Using a z-test instead of a t-test when the population standard deviation is unknown is a standard mistake. Another error is incorrectly substituting the sample variance (s2s^2) for the sample standard deviation (ss) in the denominator.

Worked example

A machine is supposed to fill bottles with 500 mL of water. A sample of 16 bottles has a mean volume of 495 mL and a standard deviation of 8 mL. Test if the machine is underfilling at α=0.05\alpha = 0.05.

H0:μ=500H_0: \mu = 500. Ha:μ<500H_a: \mu < 500. n=16n = 16, xˉ=495\bar{x} = 495, s=8s = 8, μ0=500\mu_0 = 500. Compute standard error: SE=sn=816=2SE = \frac{s}{\sqrt{n}} = \frac{8}{\sqrt{16}} = 2. Compute t-statistic: t=xˉμ0SE=4955002=2.5t = \frac{\bar{x} - \mu_0}{SE} = \frac{495 - 500}{2} = -2.5. Degrees of freedom: df=161=15df = 16 - 1 = 15. The critical value for a one-tailed test at α=0.05\alpha = 0.05 with df=15df = 15 is 1.753-1.753. Since 2.5<1.753-2.5 < -1.753, we reject H0H_0. The machine is underfilling.

FAQ

Run your own problem

References: OpenStax Introductory Statistics, Chapter 9 · Khan Academy Unit: Significance tests (hypothesis testing)

See also