Professional Documents
Culture Documents
Hypothesis Testing For The Mean
Hypothesis Testing For The Mean
Hypothesis Testing For The Mean
H 0: μ = μ 0,
H 1: μ ≠ μ 0.
In this case, the null hypothesis is a simple hypothesis and the alternative hypothesis is a two-sided
hypothesis (i.e., it includes both μ < μ 0 and μ > μ 0). We call this hypothesis test a two-sided test. The second
and the third cases are one-sided tests. More specifically, the second case is
H 0: μ ≤ μ 0,
H 1: μ > μ 0.
Here, both H 0 and H 1 are one-sided, so we call this test a one-sided test. The third case is very similar to the
second case. More specifically, the third scenario is
H 0: μ ≥ μ 0,
H 1: μ < μ 0.
¯ X1 + X2 + . . . + Xn
X=
n
to define our statistic. In particular, if we know the variance of the X i's, Var(X i) = σ 2, then we define our test
statistic as the normalized sample mean (assuming H 0):
¯
X − μ0
W(X 1, X 2, ⋯, X n) = .
σ / √n
¯
X − μ0
W(X 1, X 2, ⋯, X n) = ,
S / √n
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 1/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
S=
√
1
n
∑ (X − X) =
n − 1k=1 k
¯
2
√ (∑ 1
n − 1 k=1
n
2
Xk
¯2
− nX .
)
In any case, we will be able to find the distribution of W, and thus we can design our tests by calculating error
probabilities. Let us start with the first case.
Here, we are given a random sample X 1,X 2,...,X n from a distribution. Let μ = EX i. Our goal is to decide
between
H 0: μ = μ 0,
H 1: μ ≠ μ 0.
¯
Example 8.22, which we saw previously is an instance of this case. If H 0 is true, we expect X to be close to
μ 0, and so we expect W(X 1, X 2, ⋯, X n) to be close to 0 (see the definition of W above).
Therefore, we can suggest the following test. Choose a threshold, and call it c. If | W | ≤ c, accept H 0, and if
| W | > c, accept H 1. How do we choose c? If α is the required significance level, we must have
Example 8.24
Let X 1,X 2,...,X n be a random sample from a N(μ, σ 2) distribution, where μ is unknown but σ is known. Design
a level α test to choose between
H 0: μ = μ 0,
H 1: μ ≠ μ 0.
Solution
As discussed above, we let
¯
X − μ0
W(X 1, X 2, ⋯, X n) = .
σ / √n
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 2/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
P( | W | > c | H 0) = α.
α
Thus, we conclude P(W > c | H 0) = 2 . Therefore,
c = z α.
2
Therefore, we accept H 0 if
| |
¯
X − μ0
≤ z α,
σ / √n 2
Relation to Confidence Intervals: It is interesting to examine the above acceptance region. Here, we accept
H 0 if
| |
¯
X − μ0
≤ z α.
σ / √n 2
[ ]
¯ σ ¯ σ
α
μ0 ∈ X − z , X + zα .
2
√n 2
√n
The above interval should look familiar to you. It is the (1 − α)100% confidence interval for μ 0. This is not a
coincidence as there is a general relationship between confidence interval problems and hypothesis testing
problems.
Example 8.25
For the above example (Example 8.24), find β, the probability of type II error, as a function of μ.
Solution
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 3/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
We have
(| | )
¯
X − μ0
=P < zα | μ .
σ / √n 2
¯ σ2
2
If X i ∼ N(μ, σ ), then X ∼ N(μ, n ). Thus,
(| | )
¯
X − μ0
β(μ) = P < zα | μ
σ / √n 2
( )
σ ¯ σ
= P μ0 − z α ≤ X ≤ μ0 + z α
2
√n 2
√n
=Φ z +
( α
2
μ0 − μ
σ / √n ) (
− Φ −z + α
2
μ0 − μ
σ / √n ) .
Unknown variance: The above results (Example 8.25) can be extended to the case when we do not know the
variance using the t-distribution. More specifically, consider the following example.
Example 8.26
Let X 1,X 2,...,X n be a random sample from a N(μ, σ 2) distribution, where μ and σ are unknown. Design a level
α test to choose between
H 0: μ = μ 0,
H 1: μ ≠ μ 0.
Solution
Let S 2 be the sample variance for this random sample. Then, the random variable W defined as
¯
X − μ0
W(X 1, X 2, ⋯, X n) =
S / √n
has a t-distribution with n − 1 degrees of freedom, i.e., W ∼ T(n − 1). Thus, we can repeat the
analysis of Example 8.24 here. The only difference is that we need to replace σ by S and z α by
2
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 4/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
α
t , n − 1. Therefore, we accept H 0 if
2
| W | ≤ t α , n − 1,
2
Example 8.27
The average adult male height in a certain country is 170 cm. We suspect that the men in a certain city in that
country might have a different average height due to some environmental factors. We pick a random sample
of size 9 from the adult males in the city and obtain the following values for their heights (in cm):
Assume that the height distribution in this population is normally distributed. Here, we need to decide
between
H 0: μ = 170,
H 1: μ ≠ 170.
Based on the observed data, is there enough evidence to reject H 0 at significance level α = 0.05?
Solution
Let's first compute the sample mean and the sample standard deviation. The sample mean is
¯ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9
X=
9
= 165.8
S= √S 2 = 8.25
The following MATLAB code can be used to obtain these values:
x=[176.2,157.9,160.1,180.9,165.1,167.2,162.9,155.7,166.2];
m=mean(x);
v=var(x);
s=std(x);
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 5/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
t α , n − 1 = t 0.025 , 8 ≈ 2.31
2
The above value can be obtained in MATLAB using the command tinv(0.975, 8). Thus, we
conclude
| W | ≤ t α , n − 1.
2
Therefore, we accept H 0. In other words, we do not have enough evidence to conclude that the
average height in the city is different from the average height in the country.
What if the sample is not from a normal distribution? In the case that n is large, we can say that
¯
X − μ0
W(X 1, X 2, ⋯, X n) =
S / √n
| |
¯
X − μ0
≤ z α,
S / √n 2
Let us summarize what we have obtained for the two-sided test for the mean.
¯
2 X − μ0 |W| ≤ zα
X i ∼ N(μ, σ ), σ known W= 2
σ / √n
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 6/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
¯
X − μ0
n large, X i non-normal |W| ≤ zα
W= 2
S / √n
¯
X − μ0
Xi ∼ N(μ, σ 2), σ unknown | W | ≤ tα ,n−1
W= 2
S / √n
We can provide a similar analysis when we have a one-sided test. Let's show this by an example.
Example 8.28
Let X 1,X 2,...,X n be a random sample from a N(μ, σ 2) distribution, where μ is unknown and σ is known.
Design a level α test to choose between
H 0: μ ≤ μ 0,
H 1: μ > μ 0.
Solution
As before, we define the test statistic as
¯
X − μ0
W(X 1, X 2, ⋯, X n) = .
σ / √n
¯
If H 0 is true (i.e., μ ≤ μ 0), we expect X (and thus W) to be relatively small, while if H 1 is true, we
¯
expect X (and thus W) to be larger. This suggests the following test: Choose a threshold, and call
it c. If W ≤ c, accept H 0, and if W > c, accept H 1. How do we choose c? If α is the required
significance level, we must have
Here, the probability of type I error depends on μ. More specifically, for any μ ≤ μ 0, we can
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 7/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
write
( )
¯
X − μ0
=P >c | μ
σ / √n
( )
¯
X−μ μ − μ0
=P + >c | μ
σ / √n σ / √n
( )
¯
X−μ μ0 − μ
=P >c+ | μ
σ / √n σ / √n
( )
¯
X−μ
≤P >c | μ ( since μ ≤ μ 0)
σ / √n
¯
X−μ
= 1 − Φ(c) ( since given μ, ∼ N(0, 1) ).
σ / √n
c = z α.
Therefore, we accept H 0 if
¯
X − μ0
≤ z α,
σ / √n
The above analysis can be repeated for other cases. More generally, suppose that we are given a random
sample X 1,X 2,...,X n from a distribution. Let μ = EX i. Our goal is to decide between
H 0: μ ≤ μ 0,
H 1: μ > μ 0.
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 8/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
if σ =
√Var(Xi) is known, and as
¯
X − μ0
W(X 1, X 2, ⋯, X n) = ,
S / √n
¯
if σ is unknown. If H 0 is true (i.e., μ ≤ μ 0), we expect that X (and thus W) to be relatively small, while if H 1
¯
is true, we expect X (and thus W) to be larger. This suggests the following test: Choose a threshold c. If W ≤ c
, accept H 0, and if W > c, accept H 1. To choose c, note that
Note that the last inequality resulted because if we make μ larger, the probability of W > c can only increase.
In other words, we assumed the worst case scenario, i.e, μ = μ 0 for the probability of error. Thus, we can
choose c such that P(W > c | μ = μ 0) = α. By doing this procedure, we obtain the acceptance regions
reflected in Table 8.3.
¯
X − μ0
X i ∼ N(μ, σ 2), σ known W=
W ≤ zα
σ / √n
¯
X − μ0
n large, X i non-normal W= W ≤ zα
S / √n
¯
X − μ0
Xi ∼ N(μ, σ 2), σ unknown W= W ≤ tα , n − 1
S / √n
Note that the tests mentioned in Table 8.3 remain valid if we replace the null hypothesis by μ = μ 0. The
reason for this is that in choosing the threshold c, we assumed the worst case scenario, i.e, μ = μ 0. Finally, if
we need to decide between
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 9/10
27/02/2024, 23:50 Hypothesis Testing for the Mean
H 0: μ ≥ μ 0,
H 1: μ < μ 0,
we can again repeat the above analysis and we obtain the acceptance regions reflected in Table 8.4.
¯
X − μ0
X i ∼ N(μ, σ 2), σ known W=
W ≥ − zα
σ / √n
¯
X − μ0
n large, X i non-normal W ≥ − zα
W=
S / √n
¯
X − μ0
Xi ∼ N(μ, σ 2), σ unknown W= W ≥ − tα , n − 1
S / √n
← previous
next →
https://www.probabilitycourse.com/chapter8/8_4_3_hypothesis_testing_for_mean.php 10/10