You are on page 1of 12

Hypothesis Testing of population mean

Given sample data, we want to test if the population mean is a


0


Before we start testing, we first need to define the following

1)
0
H : Null hypothesis
Our assumption of the population mean. Eg
0 0
: H =
2)
1
H : Alternative hypothesis
How the population mean is different. Eg:
0 1
: H > or
0 1
: H < or
0 1
: H

Lets use an example to illustrate

The manufacturer of coke cans claims that the mean weight of coke cans (i.e. population
mean) is 100 g and that the weight of a randomly selected coke can is normally distributed
and the variance is 10. You take a random sample of 20 coke cans and find that the mean
weight is 102 g hence you suspect that the population mean should be more than 100 g.

In this example, we want to test whether the weight of coke can is more than the 100 g that is
claimed by the manufacturer. Hence the writing of
0
H and
1
H will be

0
1
1
00 :
00
1
:
H
H

=
>


Let X be the random variable the weight of a coke can

Assume
0
H is true,
( ) ~ N 100,10 X

Then the mean weight of 20 coke cans will be
10
~ N 100,
20
X
| |
|
\


Lets find the probability of obtaining a sample whose mean exceed 102

( )
10
P 102 normalcdf 102, e99,100, 0.00234
20
X
| |
> = =
|
|
\


The probability of getting a sample that exceeds our sample mean of 102 is only 0.00234.
This probability is called the p-value.

p-value is defined as probability of obtaining a test statistic at least as extreme as the one
that was actually observed, assuming that the null hypothesis is true.

This value is very small, can we now say that 100 > ?

The question now is, how small is small enough for us to conclude that 100 > ?

In any statistical test we are doing, there will be errors. For example, in the above example,
the probability of getting a sample that exceeds our sample mean of 102 is 0.00234. Assume
we decide that this probability is small and reject
0
H . However there is still a probability of
0.00234 for it to occur if
0
H is true. In this situation, we will have made the wrong
conclusion.

There are two types of errors we can make

1) Type I error: the event of rejecting the null hypothesis when the null hypothesis was
true
2) Type II error: the event of failing to reject the null hypothesis when the null
hypothesis was false.

Level of significance of a test (denoted by %): probability of rejecting H
0
when H
0
is true
(making Type I error). This probability is fixed before the test to help us decide whether to
reject H
0
or not to reject H
0
.

In hypothesis testing, we reject
0
H when p-value
100

< .

Case 1: X is normally distributed and population variance
2
is known.

[N2001/P2/10a]
A random variable X is known to have a normal distribution with variance 36. The mean of
the distribution of X is denoted by . A random sample of of 50 observations of X has
mean 20.2. Test, at 1% level of significance level, the null hypothesis 22 = against 22 <

Since X is normally distributed and population variance
2
is known, we will be using the
Z-Test. i.e X is normally distributed.

Possible null and alternative hypothesis testing
0 1
0 1
0
0 0
0 0
0 0 1
: , :
: , :
: , :
H H
H H
H H

= <
= >
=


0
1
: 22
: 22
H
H

=
<


Under
0
H :
( ) ~ N 22, 36 X

Given that
( )
2
, ~ N X , The sample mean of n observation
2
~ N , X
n

| |
|
\


36
~ N 22,
50
X
| |
|
\


Calculation of p-value for Z-Test
( ) 0
p-value= P < for %? X x < <
( ) 0
p-value= P < for %? X x > >
( )
( )
0
p-value=2P <
p-value
%?
or for
%? =2P <
X x
X x

)
<
>


( )
99
p-value P 20.2
normalcdf 10 ,
36
50
20.2, 22,
0.0169
X = <
| |
=
|
|
\
=


We can also use the GC Z-Test to find the p-value.

Press STAT button to select the TESTS menu

Key in the data as shown.



Note that the in the GC Z-Test, is the population standard deviation.

Possible conclusion
1) Since p-value
100

< . We reject
0
H and conclude that we have sufficient evidence at
% level of significance to [write in context to question]
2) Since p-value>
100

. We do not reject
0
H and conclude that we have insufficient
evidence % level of significance to [write in context to question]

Since p-value=0.0169>0.01. We do not reject
0
H and conclude that we have insufficient
evidence at 1% level of significance to say that the mean is less than 22.



Case 2: X is normally distributed and population variance
2
is not known.

For this type of question, the question will usually either give you x

and
2
x

, or the
sample variance. Given these data we need to estimate the population variance.

Sample mean and variance

From n sample observation
1 2 3 n
X X X X + + + +

Sample mean :
1
x x
n
=


Sample variance :
( ) ( )
2 2
2 2
1 1
x
s x x x x
n n
= =



Unbiased estimator for the population
2

( )
( )
2
2
2
2
2
1
1 1
[given in MF15]
1 1
x
n
s
n
x
x x x
n n n
=

| |
|
= =
|
\





When we estimated the population variance, we are introducing errors. Hence, X will not be
normally distributed. Instead it now follows the Student distribution.

Given that
( )
2
, ~ N X s where
2
s is the unbiased estimator for the population variance.

The random variable
2
T
X
n
s

=

follows a Student distribution with degree of freedom 1 n .
It is written as

( )
2
~ t 1
X
n
T n



Explanation of degree of freedom (not in mathematical terms)

When we are estimating the population variance using n values, we are assuming that any set
of n values taken from the population will give us the same unbiased estimator. However,
since the unbiased estimator for variance is assumed, the first 1 n data can take any values,
the
th
n data must be such that when this set of data is used to calculate the unbiased estimator
for variance, it will be the same value.

[N2008/P2/Q6]
In a mineral water from a certain source, the mass of calcium, mg X , in a one-litre bottle is a
normally distributed random variable with mean . Based on observations over a long
period, it is known that 78 = . Following a period of extreme weather, 15 randomly chosen
bottles of the water were analysed. The mass of calcium in the bottles are summarised by
1026.0 x =

,
2
77265.90 x =


Test, at the 5% significance level, whether the mean mass of calcium in a bottle has changed.

Since X is normally distributed and population variance
2
is unknown, we will be using
the T-Test. i.e X is follows the Student distribution.

1026.0
68.4
15
x = =

( )
( )
2
2
2 2 1
1
22.5
x
x
n n

(
(
(

= =



0
1
78
: 78
:
H
H


=


Under
0
H ,
( )
2
~ N 78, 22.5 X
( )
2
78
22.5
~ t 5 1
15
1 T
X
=

Calculation of p-value for T-Test
0
0
2
p-value=P < for %?
x
T
s
n


| |
|
<
|
|
<
\

0
0
2
p-value=P for %?
x
T
s
n


| |
|
> <
|


>
|
\

0
2
0
0
2
p-value=2P <
p-value=2P
%?
or for
%?
x
T
s
n
x
T
s
n

| |
|
<
|
|
\
| |
|
> <

|
|

\


Since 68.4 78 x = < ,
( ) ( )
99
2
68.4 78
p-value 2P 2P 1.65247 2tcdf 10 , 1.65247,15 1 0.121
22.5
15
T T
| |
|

|
= < = < = =
|
|
\


Using the GC to find p-value



Note that the in the GC T-Test, Sx is the unbiased estimator for population standard
deviation.

Since p-value 0.121 0.05 = > , we do not reject
0
H and conclude that we have insufficient
evidence at 5% level of significance to claim that there is a change in mass of calcium.


Note: For large number of observations ( 30 n > ), the Student distribution can be
approximated with a standard normal distribution. Hence we can also do a Z-Test.

Case 3: X is not normally distributed and number of observations is large.

We can use the Central Limit Theorem to approximate X to a normal distribution.

[N2007/P2/Q7]
A large number of students in a college have completed a geography project. The time,
hours, taken by a student to complete the project is noted for a random sample of 150
students. The results are summarised by
2
4626, 147691 x x = =

.
Find unbiased estimates for the population mean and variance.

Test, at 5% significance level, whether the population mean time for student to complete the
project exceeds 30 hours.

State, giving reason, whether any assumption about the population are needed in order for the
test to be valid.

The unbiased estimate of the population mean
4626
30.84
150
x
n
= = =


The unbiased estimate of the population variance

( )
2
2
2 2
1 1 147691
30.84 33.7259.... 33.7
1 150 150
x
x
n n

(
(
(
= = =
(
(



0
1
: 30
30 : H
H

=
>


Under
0
H and since number of observations is large (>50), by central limit theorem
33.7259
~ N 30,
150
X
| |
|
\
approximately



Since p-value=0.0382>0.05, we reject
0
H . and conclude that we have sufficient evidence at
5% level of significance that the mean time a student takes to complete the project exceeds 30
hours.

The amount of time taken by the student to complete the project is independent of each other.

Case 4: X is not normally distributed and number of observations is small.

For these cases, we cannot use the central limit theorem to approximate the X to normal
distribution.

We need to assume that X is normally distributed, then it is either case 1 (
2
known) or
case 2 (
2
unknown and

2
used).

[FM 1999/P2/Q7i]
The manufacturer of an electric water heater claim that their heater will heat 500 litres of
water from a temperature of
O
10 C to a temperature of
O
35 C in , on average no longer than
12 minutes. In order to test their claim, 14 randomly chosen heaters are bought and time
times ( x minutes) to heat 500 litres of water from
O
10 C to
O
35 C are measured. Corrected
to 1 decimal place, the results are as follows.

13.2 12.2 11.4 14.5 11.6 12.9 12.4 10.3 12.3 11.8 11.0 13.0
12.1 12.6
2
171.3, 2109.81 x x ( = =




Stating, any assumptions necessary for validity, test the manufacturers claim at 10%
significance level using a t-test.

Let X be the random variable the time taken to heat the water.

Assuming that X is normally distributed, we will use the T-Test.
Note the special way to define the null and alternative hypothesis. In this question, the
manufacturer claims that the time is less than 12.

0
1
12 The manufacturer claim is not true
12 The manufacturer claim
:
: is true H
H

=
<

Under
0
H ,

( )
2
~ N 12, X

( )
0
2
~ t 13)
14
X
T

=
Using the GC

Since p-value=0.796>0.1, we do not reject
0
H and conclude that we have insufficient
evidence at 10% level of significance to support the manufacturers claim that the heating
time is less than 12 minutes.
Summary

Determine H
0
: =
0

Determine H
1
:
<
0
, >
0
or
0

2
known?

1
Calculate x x
n
=

2
0
~ N , X
n

| |
|
\
( ) 0
p-value=P < for %? X x < <
( ) 0
p-value=P < for %? X x > >
( )
( )
0
p-value=2P <
p-value
%?
for
%? =2P <
X x
X x

)
<
>
Z-Test
( )
0
2
~ 1
X
T t n
n

=
0
0
2
p-value=P < for %?
x
T
s
n


| |
|
<
|
|
<
\
0
0
2
p-value=P for %?
x
T
s
n


| |
|
> <
|


>
|
\
T-Test
0
2
0
0
2
p-value=2P <
p-value=2P
%?
for
%?
x
T
s
n
x
T
s
n

| |
|
<
|
|
\
| |
|
> <

|
|
)

\
50? n
yes
no
yes
no
approximately (optional)
2
estimated?
Normal
distribution?
50? n
CLT
yes
no
no

( )
( )
2
2
2 2
2
1 1
1 1 1
x
x
n
s x x x
n n n n

(
(
= = =
(



Assume
Normal
yes
Comparison between p-value and critical values

Test p-value
Z-Test
T-Test
Non-standardised Standardised
1 0
: H <



To reject:
( )
2
99
p-value P
normalcdf 10 , , ,
o
X x
x
n

= <
| |
=
|
\

p-value
100

<
To reject:
critic
2
al
0
invNorm ,
100
, x
n

| |
=
|
\

critical x x <
To reject:
critical
invNorm , 0,1
100
z
| |
=
|
\

0
test
2
x
z
n

=
test critical
z z <
To reject:
critical
invT , 1
100
t n
| |
=
|
\

0
test
2
x
t
n

=
test critical
t t <


p-value






1 0
: H >



To reject:
( )
2
99
p-value P
normalcdf ,10 , ,
o
X x
x
n

= >
| |
=
|
\
p-value
100

<
To reject:
critica
0
l
2
invNorm 1 , ,
100
x
n

| |
=
|
\
critical x x >
To reject:
critical
invNorm 1 , 0,1
100
z
| |
=
|
\

0
test
2
x
z
n

=
test critical
z z >
To reject:
critical
invT 1 , 1
100
t n
| |
=
|
\

0
test
2
x
t
n

=
test critical
t t >
1 0
: H

To reject:
( )
p-value=2P < % X x <
OR
( )
p-value=2P < % X x >


To reject:
x must lies in the rejection
region. It is too messy to do as
there will be two critcal values,
hence usually standardised Z Test
will be easier.
critical
invNor
0.5
, m 1 0 1 ,
100
z
| |
=
|
\
0
test
2
x
z
n

=
test critical
z z >
To reject:
critical
0
invT 1 , 1
100
.5
t n
| |
=
|
\

0
test
2
x
t
n

=
test critical
t t >



p-value

You might also like