In this section, we consider a hypothesis test of the population mean \(\mu\). This procedure is based on a random sample of \(n\) observations from a population with unknown mean \(\mu\) and unknown population variance \(\sigma^2\). We assume that either the population is normal or the sample size is at least \(30\).
We want to test the null hypothesis \(H_0: \mu = \mu_0\) versus \(H_a: \mu > \mu_0\)
The test statistic is
\[t = \frac{\bar x - \mu_0}{s/\sqrt{n}}\]
which has a \(t\) distribution with \(n-1\) degrees of freedom under the assumption that the null hypothesis is true.
The p-value is
\[P(T > t) = 1-\text{pt}(t,n-1)\]
If the p-value is less than or equal to \(\alpha\) then we reject the null hypothesis and there is sufficient evidence to conclude the alternative hypothesis.
Otherwise we fail to reject the null hypothesis and there is insufficient evidence to conclude the alternative hypothesis.
Example 1: An engineering research center claims that through the use of a new computer control system, cars should achieve, on average, an additional 3 miles per gallon of gas. A random sample of \(25\) cars was used to evaluate this product. The sample mean increase in miles per gallon achieved was \(3.8\) with a standard deviation of \(1.8\) miles per gallon. Test the appropriate hypothesis at \(\alpha = 0.05\)
Click For AnswerWe are interested in testing \(H_0:\mu = 3\) versus \(H_a:\mu > 3\) where \(\mu =\) true population mean increase in miles per gallon. To find the test statistic and p-value, we can use R.
n <- 25
xbar <- 3.8
s <- 1.8
t <- (xbar-3)/(s/sqrt(n))
t
[1] 2.222222
pval <- 1-pt(t,n-1)
pval
[1] 0.01797407
The p-value tells us that we only have a 2% chance of seeing a sample result that large or larger if the null hypothesis is really true. Since the p-value is less than \(\alpha\), we reject the null hypothesis and conclude that cars using the new system did achieve, on average, an additional 3 miles per gallon.
It is required that the random sample comes from a normal population since the sample size is less than thirty.
We want to test the null hypothesis \(H_0: \mu = \mu_0\) versus \(H_a: \mu < \mu_0\)
The test statistic is
\[t = \frac{\bar x - \mu_0}{s/\sqrt{n}}\]
which has a \(t\) distribution with \(n-1\) degrees of freedom under the assumption that the null hypothesis is true.
The p-value is
\[P(T < t) = \text{pt}(t,n-1)\]
If the p-value is less than or equal to \(\alpha\) then we reject the null hypothesis and there is sufficient evidence to conclude the alternative hypothesis.
Otherwise we fail to reject the null hypothesis and there is insufficient evidence to conclude the alternative hypothesis.
Example 2: A major car manufacturer wants to test a new engine to determine whether it meets new air pollution standards. The mean emission of all engines of this type must be less than 20 parts per million of carbon. Ten engines are manufactured for testing purposes, and the emission level of each is determined. The data (in parts per million) are: 15.6, 16.2, 22.5, 20.5, 16.4, 19.4, 19.6, 17.9, 12.7, 14.9
Is there sufficient evidence to allow the manufacturer to conclude that this type of engine meets the pollution standard? Test at \(\alpha = 0.10.\)
Click For AnswerWe are interested in testing \(H_0:\mu = 20\) versus \(H_a:\mu < 20\) where \(\mu =\) mean emission of all engines. To find the test statistic and p-value, we can use R.
First, we enter the data
x <- c(15.6, 16.2, 22.5, 20.5, 16.4, 19.4, 19.6, 17.9, 12.7, 14.9)
Then, we can use the t.test command to find the test statistic and p-value:
t.test(x,alternative="less",mu=20)
One Sample t-test
data: x
t = -2.6029, df = 9, p-value = 0.0143
alternative hypothesis: true mean is less than 20
95 percent confidence interval:
-Inf 19.28135
sample estimates:
mean of x
17.57
Or we can use R to find the test statistic and p-value manually:
n <- length(x)
xbar <- mean(x)
s <- sd(x)
t <- (xbar-20)/(s/sqrt(n))
t
[1] -2.602891
pval <- pt(t,n-1)
pval
[1] 0.01430115
The p-value tells us that we only have a 1% chance of seeing a sample result that small or smaller if the null hypothesis is really true. Since the p-value is less than \(\alpha\), we reject the null hypothesis and conclude that there is sufficient evidence that this type of engine meets the pollution standard.
It is required that the random sample comes from a normal population since the sample size is less than thirty.
We want to test the null hypothesis \(H_0: \mu = \mu_0\) versus \(H_a: \mu \ne \mu_0\)
The test statistic is
\[t = \frac{\bar x - \mu_0}{s/\sqrt{n}}\]
which has a \(t\) distribution with \(n-1\) degrees of freedom under the assumption that the null hypothesis is true.
The p-value is
\[2P(T > |t|) = 2*(1-\text{pt(abs}(t),n-1))\]
If the p-value is less than or equal to \(\alpha\) then we reject the null hypothesis and there is sufficient evidence to conclude the alternative hypothesis.
Otherwise we fail to reject the null hypothesis and there is insufficient evidence to conclude the alternative hypothesis.
Example 3: A machine is designed to discharge a mean of 12 ounces of cereal per box. A sample of 101 boxes yielded an average fill amount of 11.88 ounces with a standard deviation of 1.3 ounces. Test the hypothesis that the machine is filling the boxes correctly at \(\alpha = 0.01\)
Click For AnswerWe are interested in testing \(H_0:\mu = 12\) versus \(H_a:\mu ne 12\) where \(\mu =\) true population mean amount of cereal per box. To find the test statistic and p-value, we can use R.
n <- 101
xbar <- 11.88
s <- 1.3
t <- (xbar-12)/(s/sqrt(n))
t
[1] -0.9276808
pval <- 2*(1-pt(abs(t),n-1))
pval
[1] 0.3558068
The p-value tells us that we have a 36% chance of seeing a sample result that is that extreme in either direction if the null hypothesis is really true. Since the p-value is greater than \(\alpha\), we fail to reject the null hypothesis and conclude that there is insufficient evidence that the machine is filling the boxes incorrectly.
Since the random sample is large we do not have to assume that our data comes from a normal population.