- A method of statistical inference to test assumptions (hypotheses) about population parameters.
- Null Hypothesis (H₀): The default assumption.
- Alternative Hypothesis (H₁): What we aim to support.
Suppose a factory claims its light bulbs last 1000 hours on average. We suspect they don’t.
\[ z = \frac{\bar{x} - \mu}{\sigma / \sqrt{n}} \]
Where:
\[ p = P(Z \geq |z|) \]
library(ggplot2) set.seed(123) data <- rnorm(100, mean=995, sd=10) sample_mean <- mean(data) sample_sd <- sd(data) n <- length(data) z <- (sample_mean - 1000) / (sample_sd / sqrt(n)) z
## [1] -4.487149
ggplot(data.frame(x=data), aes(x)) + geom_histogram(bins=30, fill="lightblue", color="black") + geom_vline(xintercept=1000, color="red", linetype="dashed") + labs(title="Sample Light Bulb Lifespan", x="Hours", y="Count")