- Hypothesis testing is a method of making decisions using data.
- We test an assumption (the “null hypothesis”) against an alternative.
- Common in science, medicine, and engineering.
2025-10-26
A battery manufacturer claims their batteries last at least 100 hours on average.
From production data, the manufacturer calculated the population standard deviation to be 5
Another competitor tests 50 batteries and gets a mean of 98.5 hours.
Is this enough evidence to reject the manufacturer’s claim?
We use a one-sample z-test for the mean to compare a sample mean (obtained from the competitor) to a known population mean (as claimed by the manufacturer):
\[ z = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}} \]
Where:
- \(\bar{x}\) = sample mean
- \(\mu_0\) = claimed population mean
- \(\sigma\) = population standard deviation
- \(n\) = sample size
z_test <- function(xbar, mu0, sigma, n) {
z <- (xbar - mu0) / (sigma / sqrt(n))
p <- 2 * (1 - pnorm(abs(z)))
list(z = z, p = p)
}
z_test(98.5, 100, 5, 50)
## $z ## [1] -2.12132 ## ## $p ## [1] 0.03389485
The z-test statistic falls in the shaded rejection region beyond ±1.96 (from α = 0.05 according to standard practice), indicating a significant result.
Since the visualized region p-value (red) extends outside the blue line (p < α with 0.034 < 0.05) we reject the null hypothesis (the base claim by the manufacturer)