Hypothesis Testing

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Test of Hypothesis

MAT 3103: Computational statistics and Probability


Chapter 9: Test of Hypothesis

Hypothesis test:
A hypothesis test is a formal way to make a decision based on statistical analysis. A hypothesis
test has the following general steps:
• Set up two contradictory hypotheses. One represents our assumption.
• Perform an experiment to collect data.
• Analyze the data using the appropriate distribution.
• Decide if the experimental data contradicts the assumption or not.
• Translate the decision into a clear, non-technical conclusion.
We will build up all the pieces we need, then put them together to test hypothesis.
Parameter: It is the unknown constant characteristic of the population observations. Function of
population, population mean (µ), population variance (  2 ) are parameters.
Statistic: It is the function of sample observations. Sample mean ( x ), sample variance ( s 2 ) are
statistic.
Hypothesis: A hypothesis is a statement about one or more of parameter(s) of a population
which we want to verify on the basis of information contained in a sample.
Example: Internet server claims that computer users in AIUB spend on the average 15 hours per
week on browsing. We conduct a survey based on a sample of 250 users to arrive at a correct
decision. Here, the server's claim is referred to as a hypothesis.

1
Test of Hypothesis

Null hypothesis: It is a statement which tells us that no difference exits between the parameter
and the statistic, i.e., given the test scores of two random samples , does one group differ from
the other? A possible null hypothesis is, 𝐻0 : 𝜇1 = 𝜇2, [𝜇1 = mean of population 1, 𝜇2 = mean of
population 2].
Alternative hypothesis: The alternative hypothesis is the logical opposite of the null hypothesis.
The rejection of a null hypothesis leads to the acceptance of the alternative hypothesis, i.e.,
Possible alternative hypothesizes are, 𝐻1 : 𝜇1 ≠ 𝜇2 , or, 𝐻1 : 𝜇1 > 𝜇2 or, 𝐻1 : 𝜇1 < 𝜇2.
Test statistic: It is the function of sample observations which is used to verify the null
hypothesis.
Level of significance: It is the probability with which we want to risk rejecting the null
hypothesis even though it is true. We denote it by α; usually α = 0.05.

Acceptance region: If the value of the test statistic falls into the probability space of the
distribution of the test statistic and lead us to accept the null hypothesis then the probability
space is called the acceptance region.
Critical Region: The probability space in which the test statistic falls and leads us to reject the
null hypothesis is called critical region or rejection region. In the given figure the critical and
acceptance region are shown.
If Z ≥ Zα/2, H0 is rejected in favor of H1.
If − Z ≤ − Zα/2, H0 is rejected in favor of H1.
If lZl ≥ Zα/2, H0 is rejected in favor of H1.

2
Test of Hypothesis

Type I error: It is the probability of rejecting the null hypothesis when the null hypothesis is
true.
Type II error: It is the probability of accepting the null hypothesis when the null hypothesis is
false.
Example: Consider a defendant in a trial. The null hypothesis is "defendant is not guilty;" the
alternate is "defendant is guilty." A Type I error would correspond to convicting an innocent
person; a Type II error would correspond to setting a guilty person free.
Reality
Not guilty Guilty
Verdict Guilty Type I Error: Innocent goes jail Correct Decision
Not guilty Correct Decision Type II Error: Guilty goes free

Test of hypothesis:
It is the statistical process of verifying the null hypothesis using any test statistic. The steps are:
 State the null hypothesis, 𝐻0 .
 State the alternative hypothesis, 𝐻1 .
 Choose the level of significance, α.
 Select an appropriate test statistic.
 Calculate the value of the test statistic.
 Determine the critical region.
 Reject 𝐻0 if the value of the test statistics falls in the critical region; otherwise accept 𝐻0 .

Test regarding one mean:


Let 𝑥1 , 𝑥2 , … , 𝑥𝑛 be n sample observations drawn independently from a population with mean 𝜇
and variance 𝜎 2 . Let us assume that the sample observations follow normal distribution, i.e. x
~ 𝑁(𝜇, 𝜎 2 ). The problem is to test the null hypothesis 𝐻0 : 𝜇= 𝜇0 against 𝐻1 : 𝜇 ≠ 𝜇0 .
Assumptions:
𝑥̅ −𝜇0
1. 𝜎 2 is unknown and n is small (𝑛 < 30), the test statistic is: 𝑡 = ~ 𝑡𝑛−1
𝑠/√𝑛
𝑥̅ −𝜇0
2. 𝜎 2 is unknown and n is large (𝑛 ≥ 30), the test statistic is: 𝑧 = ~ 𝑁(0, 1)
𝑠/√𝑛
𝑥̅ −𝜇0
3. 𝜎 2 is known (𝑛 is small or large), the test statistic is: 𝑧 = ~ 𝑁(0, 1)
𝜎0 /√𝑛

3
Test of Hypothesis

Example 9.1: A random sample of 10 persons is selected and their level of education (in
completed years of schooling) is recorded. The sample observations are,
𝑥: 5, 2, 0, 4, 16, 14, 10, 10, 6, 5. Do you think that the average schooling years of the persons in
population is 5?
Solution: Let, 𝑥~ 𝑁 (µ, 𝜎 2 ), 𝜎 2 is unknown.
We need to test, 𝐻0 : µ = 𝜇0 = 5 vs 𝐻1 : µ ≠ 𝜇0 .
1 72 1 (∑𝑥)2 1 722
𝑥̅ = ∑𝑥 = = 7.2, 𝑠 2 = [ ∑𝑥 2 − ] = (758 – ) = 26.62.
𝑛 10 𝑛−1 𝑛 9 10
𝑥̅ −𝜇0 7.2 − 5
Test statistic: 𝑡 = = = 1.35. Since |𝑡|<𝑡9 = 2.262. So 𝐻0 is accepted.
𝑠/√𝑛 5.16/√10

Hence, we can conclude that the average schooling years can be considered as 5.

Test of equality of two means:

Example 9.2: The number of computer graduates coming out from two different universities A
and B are employed in different organizations to do job related to computer.
University Number of graduates employed in computer related job
𝐴 𝑥1 ∶ 18, 16, 15, 20, 18, 15, 12
𝐵 𝑥2 : 20, 14, 12, 22, 16, 14, 15, 10, 12, 18, 10
Do you think that the employment facility for both the universities is similar?
Solution: Let, 𝑥1 ~𝑁(𝜇1 , 𝜎12 ) , 𝑥2 ~𝑁(𝜇2 , 𝜎22 ). Also, let 𝜎12 = 𝜎22 = 𝜎 2 .
We need to test, 𝐻0 : 𝜇1 = 𝜇2 vs 𝐻1 : 𝜇1 ≠ 𝜇2 .
Both 𝑛1 = 7 and 𝑛2 = 11 are small (< 30) and 𝜎 2 is not known.
̅𝑥̅̅1̅ − ̅𝑥̅̅2̅
Test statistic: 𝑡 = 1 1
~ 𝑡(𝑛1 −1)+ (𝑛2−1) .
2
√𝑠 (𝑛 + 𝑛 )
1 2

1 114 1 (∑x1i )2 1 1142


𝑥1 = 𝑛 ∑𝑥1 =
̅̅̅ = 16.29 𝑠12 = 𝑛 [ ∑𝑥12 – ]= 6 (1898 – ) = 6.905
1 7 1 −1 𝑛1 7
1 163 1 (∑x2i )2 1 1632
𝑥2 = 𝑛 ∑𝑥2 =
̅̅̅ = 14.82 𝑠22 = 𝑛 [∑𝑥22 – ] = 10 (2569 – ) = 15.364
2 11 2 −1 𝑛2 11

16.29 – 14.82 (𝑛1 − 1)𝑠12 + (𝑛2 − 1)s22 6(6.905) + 10(15.364)


𝑡= = 0.87 𝑠2 = = 12.192
1 1 (𝑛1 − 1) + (𝑛2 − 1) 16
√12.192 ( + )
7 11

Since |𝑡|<𝑡16 = 2.12, 𝐻0 is accepted. Employment facility for students of both universities is same.

4
Test of Hypothesis

Note ̅𝑥̅̅1̅ − ̅𝑥̅̅2̅


If both 𝑛1 and 𝑛2 are large (≥ 30), then test statistic is: 𝑧 = ~ 𝑁(0, 1)
𝑠2 𝑠2
√( 1 + 2)
𝑛1 𝑛2

Test of equality of several means:


Example 9.3: There are 25 computers in an office. These computers are supplied by 5
companies in lots of 5. During working hours each computer fails to work for some time (in
hour). The failure time of different computers are shown below:
𝐶𝑜𝑚𝑝𝑎𝑛𝑦 𝐹𝑎𝑖𝑙𝑢𝑟𝑒 𝑡𝑖𝑚𝑒 (𝑖𝑛 ℎ𝑜𝑢𝑟) 𝑜𝑓 𝑐𝑜𝑚𝑝𝑢𝑡𝑒𝑟𝑠 (𝑦𝑖𝑗 ) 𝑇𝑜𝑡𝑎𝑙(𝑦𝑖 ) 𝑀𝑒𝑎𝑛(𝑦̅)
𝑖

A 1.5 1 0.5 2 3 8 1.6


B 1 0.5 0.2 0.5 0.5 2.7 0.54
C 0 2 2 0 0 4 0.8
D 2 2.5 1 2 3 10.5 2.1
E 3 3 2 2.5 2.5 13 2.6
Are the computers of different companies alike in failure time?
Solution: We need to test: 𝐻0 : 𝜇1 = 𝜇2 = 𝜇3 = 𝜇4 = 𝜇5 vs 𝐻1 : At least one of them doesn’t hold.
𝐶𝑜𝑟𝑟𝑒𝑐𝑡𝑖𝑜𝑛 𝑇𝑒𝑟𝑚, 𝐶𝑇 𝑇𝑜𝑡𝑎𝑙 𝑆𝑢𝑚 𝑜𝑓 𝑆𝑞𝑢𝑎𝑟𝑒𝑠, 𝑇𝑆𝑆
𝐺2 38.22 = ∑∑𝑦𝑖𝑗 2 – 𝐶𝑇
= = = 58.37
𝑛 25 = 85.04 – 58.3 = 26.67
𝑦𝑖 2 𝑆𝑆 (𝐸𝑟𝑟𝑜𝑟) = 𝑇𝑆𝑆 − 𝑆𝑆 (𝐶𝑜𝑚𝑝𝑎𝑛𝑦)
𝑆𝑆 (𝐶𝑜𝑚𝑝𝑎𝑛𝑦) = ∑ − 𝐶𝑇
𝑛𝑖 = 26.67 − 14.94
366.54 = 11.73
= − 58.37 = 14.94
5

ANOVA TABLE
𝑆𝑆
Sources of variation 𝑑𝑓 𝑆𝑆 𝑀𝑆 = 𝐹 𝐹4,20
𝑑𝑓
14.94
𝐶𝑜𝑚𝑝𝑎𝑛𝑦 𝑘– 1 = 5 − 1 = 4 14.94 4
= 3.73
6.43 2.87
11.73
𝐸𝑟𝑟𝑜𝑟 𝑛 – 𝑘 = 25 − 5 = 20 11.73 20
= 0.58

𝑇𝑜𝑡𝑎𝑙 𝑛 – 1 = 25 − 1 = 24 |𝐹| > 𝐹4,20 = 2.87, 𝐻0 𝑖𝑠 𝑟𝑒𝑗𝑒𝑐𝑡𝑒𝑑


Hence, the computers of different companies are not similar in respect of failure time.

5
Test of Hypothesis

Test regarding one proportion:


Let 𝑋1 , 𝑋2 , … , 𝑋𝑁 be the values of the variable 𝑋 observed from 𝑁 population units, where
1, 𝑖𝑓 𝑖 − 𝑡ℎ 𝑢𝑛𝑖𝑡 𝑝𝑜𝑠𝑠𝑒𝑠𝑠𝑒𝑠 𝑠𝑜𝑚𝑒 𝑐ℎ𝑎𝑟𝑎𝑐𝑡𝑒𝑟𝑖𝑠𝑡𝑖𝑐 𝑢𝑛𝑑𝑒𝑟 𝑠𝑡𝑢𝑑𝑦
𝑋𝑖 = {
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Let, 𝐴 = number of units in the population who possess a particular characteristic
𝑎 = number of sample units possessing the characteristic under study.
𝐴
So, 𝑃 = = proportion of population units who possess a particular characteristic.
𝑁

𝑝 = a = proportion of sample units possessing the characteristic.


n
The problem is to test, 𝐻0 : 𝑷 = 𝑃0 vs 𝐻1: 𝑷 ≠ 𝑃0 .
𝑝− 𝑃0
Test statistic, 𝑧 = ~ 𝑁 (0, 1).
𝑃 𝑄
√ 0 0
𝑛

Example 9.4: A sample of 15 students is selected from a group of 100 students and their grade
in SSC examination is recorded as follows:
Students 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Grade B C A D B C D A B C D B C C D
Do you think that 10% students get grade A?

Solution: We need to test, 𝐻0 : 𝑷 = 𝑃0 = 0.10 vs 𝐻1 : 𝑷 ≠ 𝑃0 .


2
𝑁𝑜𝑤, 𝑝 = a = = 0.13.
n 15
𝑝− 𝑃0 0.13− 0.10
Test statistic: 𝑧 = = 0.10𝑋0.90
= 0.39
𝑃 𝑄
√ 0 0 √
𝑛 15

Since |𝑧|< 1.96, 𝐻0 is accepted. It can be considered that 10% students got grade A.

6
Test of Hypothesis

Test regarding two proportions:

Example 9.5: Is the severity of the drug problem in high school the same for boys and
girls? 85 boys and 70 girls were questioned and 34 of the boys and 14 of the girls admitted to
having tried some sort of drug. What can be concluded at the 0.05 level?

Solution: We need to test 𝐻0 : 𝑃1 = 𝑃2 vs 𝐻1 : 𝑃1 ≠ 𝑃2 .


𝑝1 −𝑝2 𝑎1 +𝑎2
Test statistic, 𝑧 = ~ 𝑁 (0, 1); 𝑃 = , 𝑄 = 1 – 𝑃.
1 1 𝑛1 +𝑛2
√𝑃𝑄(𝑛 +𝑛 )
1 2

34 14 48
𝑝1 = 85 = 0.4, 𝑝2 = 70 = 0.2, 𝑝 = = 0.31, 𝑞 = 0.69
155
0.4 − 0.2
𝑧 = = 2.68
1 1
√(0.31)(0.69)( + 70)
85

Since |𝑧|> 1.96, 𝐻0 is rejected. We conclude that gender does make a difference for drug use.

Test regarding several proportions:


Example 9.6: The following are the number of defective computers of different laboratories:
Laboratories 𝐿1 𝐿2 𝐿3 𝐿4 Total
No. of defective computers (𝑂𝑖 ) 8 15 5 12 40
Are the proportions of defective computers of different laboratories similar?

Solution: We need to test 𝐻0 : 𝑃1 = 𝑃2 = 𝑃3 = 𝑃4 vs 𝐻1 : At least one of them doesn’t hold.


Test Statistic,
Oi2
2 = −n
Ei
1 2
= [8 + 152 + 52 + 122 ] − 40 = 45.8 − 40 = 5.8
10
𝑛 40
𝐸𝑖 = = = 10
𝑘 4
2
Since 𝜒 2 <𝜒𝑘−1 = 𝜒32 =7.81, 𝐻0 is accepted. Hence, the proportions of defective computers of
different laboratories are similar.

7
Test of Hypothesis

Test of independence:
Let us consider that a researcher has n units in a sample. The sample observations are classified
according to qualitative characters, say A and B as follows:
A B B Not B 𝑇𝑜𝑡𝑎𝑙 (𝑅𝑖 )
A 𝑂11 = 𝑎 𝑂12 = 𝑏 𝑅1 = 𝑎 + 𝑏
Not A 𝑂21 = 𝑐 𝑂22 = 𝑑 𝑅2 = 𝑐 + 𝑑
Total (𝐶𝑗 ) 𝐶1 = 𝑎 + 𝑐 𝐶2 = 𝑏 + 𝑑 𝑛 = 𝑅1 + 𝑅2 + 𝐶1 + 𝐶2

Here, 𝑎, 𝑏, 𝑐, 𝑑 are observed frequencies in different cells. 𝑛 = 𝑂𝑖𝑗


𝑂𝑖𝑗 = observation of 𝑖 𝑡ℎ row and 𝑗 𝑡ℎ column recorded from the experiment.
𝑅𝑖 𝐶𝑗
𝐸𝑖𝑗 = = expected frequency corresponding to 𝑖 𝑡ℎ row and 𝑗 𝑡ℎ column under 𝐻0
𝑛

We need to test, 𝐻0 : The characters A and B are independent vs 𝐻1 : They are not independent.

2
𝑂𝑖𝑗 2
Test statistic: 𝜒 2 = ∑∑ – 𝑛 ~ 𝜒(𝑟 −1) ( 𝑐 −1) . Here, r = no. of rows and c = no. of columns.
𝐸𝑖𝑗

𝑛(𝑎𝑑−𝑏𝑐)2
For r = 2 and c = 2, 𝜒 2 = (𝑎+𝑏)(𝑎+𝑐)(𝑏+𝑑)(𝑐+𝑑) ~ 𝜒12 .

Example 9.7: 150 computer graduates are interviewed and are classified according to their result
and job satisfaction. Do you think that the graduates with good result are satisfied with their job?
Job satisfaction
Result Total
Yes No
Good 22 58 80
Not good 20 50 70
Total 42 108 150

Solution: 𝐻0 : Job satisfaction does not depend on good result


𝐻1 : The good result and job satisfaction are associated
n(ad−bc)2 150(22X50−22X58)2
Test statistic: χ2 = (a+b)(a+c)(b+d)(c+d) = = 0.02
80X70X42X108

Since χ2 < χ12 = 3.84, 𝐻0 is accepted. So, job satisfaction does not depend on good result.

8
Test of Hypothesis

Example 9.8: The following are number of emails of different organizations, where emails are
classified according to local and foreign emails. The classified results are shown below:

Origin of emails Emails of organizations (𝑂𝑖𝑗 )

O1 O2 O3 O4 Total

Local 8 22 25 20 75
Foreign 17 73 25 10 125
Total 25 95 50 30 200
Is there any association between origin of emails and organizations?

Solution: 𝐻0 : Origin of emails does not depend on organization


𝐻1 : Origin of emails depends on organization.

Origin of emails Emails of organizations (𝐸𝑖𝑗 )


O1 O2 O3 O4 Total
Local 9.375 35.625 18.75 11.25 75
Foreign 15.625 59.375 31.25 18.75 125
Total 25 95 50 30 200
Oij2 82 222 102
Test statistic:  2 =   −n = + + ⋯+ − 200 = 222.88 – 200 = 22.88
Eij 9.375 35.625 18.75

Since χ2 > χ23 = 7.815, 𝐻0 is rejected. Hence, origin of emails depends on organization.

Hints 𝑅1 𝐶1 75 × 25
𝐸11 = = = 9.375
𝑛 200

9
Test of Hypothesis

Exercise 9

9.1 Among 157 African-American men, the mean systolic blood pressure was 146 mm Hg with a
standard deviation of 27. We wish to know if on the basis of these data, we may conclude that
the mean systolic blood pressure for a population of African-American is 140.

9.2 Are the proportions of road accidents similar in various highways of Bangladesh?
Highways 1 2 3 4 Total
No. of road accidents (Oi) 50 42 32 82 206

10
Test of Hypothesis

9.3 Is there any association between subjects taught and job satisfaction?
Job Subjects taught (Oij)
Total
satisfaction BBA EEE CS CSE SE
Yes 12 22 18 15 20 87
No 18 32 30 15 25 120
Total 30 54 48 30 45 207

9.4 Are the proportions of female students similar in various departments of AIUB?
Departments 1 2 3 4 Total
No. of female students (Oi) 250 450 150 150 1000

11
Test of Hypothesis

9.5 For a sample of size 36, ∑x = 761.6, ∑x2 = 16125.5. Is the population mean 21?

9.6 A company claims that its batteries have a mean life of 100 hours. You try to verify this for a
sample of size 21 with mean 97 hours and variance 9 hours.

9.7 Out of 25 students, 8 are female. Is the overall proportion of female students 0.40 in AIUB?

12
Test of Hypothesis

9.8 A researcher claims that 10-year old children watch 6.6 hours of TV daily on average. You
try to verify this for a sample of size 100 with mean 6.1 hours and standard deviation 2.5 hours.

9.9 Is the probation problem the same for boys and girls at AIUB? CGPA of 100 boys
and 125 girls were randomly checked. 25 boys and 18 girls were under probation.

13
Test of Hypothesis

9.10 The information about daily temperature (in 0 Celsius) of two months are as:
Month 1 𝑛1 = 31 ∑𝑥1 = 1032 𝑠1 2 = 1.41
Month 2 𝑛2 = 30 ∑𝑥2 = 1035 𝑠2 2 = 1.09
Do you think that the temperature of both the months are similar?

9.11 Is high blood pressure associated with heart problem?


Heart Problem
Blood Pressure
Yes No
High 150 120
Not High 122 158

14
Test of Hypothesis

9.12 A group of students are classified by their residential origin and full attention to learning:
Full attention
Residential origin Total
Yes No
Rural 138 64 202
Urban 64 84 148
Total 202 148 350
Is there any association between origin and full attention?

9.13 Are the computers of different companies alike in failure time?


Company Failure time (in hour) of computers (𝑥𝑖𝑗 )
A 120 122 110 125 118 ∑∑𝑥𝑖𝑗 = 2167
B 100 105 108 110 100
C 95 90 80 90 85 ∑∑𝑥𝑖𝑗 2 =238943
D 125 130 114 125 115

15
Test of Hypothesis

9.17 The information about salary of two different institutions (in taka) are as:
Institution 1 𝑛1 = 15 ∑𝑥1 = 16875 𝑠1 2 = 5625
Institution 2 𝑛2 = 20 ∑𝑥2 = 26500 𝑠2 2 = 50625
Do you think that the salary information of both institutions are similar?

9.18 A toothpick manufacturer wants every box to contain exactly (on average) 500 toothpicks.
In a random sample of 25 boxes, mean is 498 toothpicks and standard deviation is 9 toothpicks.

16
Test of Hypothesis

17
Test of Hypothesis

18
Test of Hypothesis

Sample MCQs
1. A quality control specialist took a random sample of n = 10 pieces of gum and measured their
thickness and found the mean 7.6 and standard deviation 0.10. Do you think that the mean
thickness of the spearmint gum it produces is 7.5?

a) Reject the null hypothesis


b) Accept the null hypothesis
c) Not concluded
d) None of the above

2. The information about daily temperature (in ° Celsius) of two months are as:
Month 1 𝑛1 = 31 Σ𝑥1 = 2042 𝑠12= 2.31
Month 2 𝑛2 = 30 Σ𝑥2 = 2045 𝑠22= 2.19
Do you think that the temperature of both the months are similar?

a) Null hypothesis is accepted


b) Null hypothesis is rejected
c) Both a and b
d) None of the above

3. The information about daily temperature (in ° Celsius) of two cities of different days are as:
City 1 𝑛1 = 11 Σ𝑥1 = 204 𝑠12= 4
City 2 𝑛2 = 15 Σ𝑥2 = 209 𝑠22= 5
Do you think that the temperature of both the cities are similar?

a) Null hypothesis is accepted


b) Null hypothesis is rejected
c) Both a and b
d) None of the above

4. Is gender independent of education level? A random sample of 395 people were surveyed, and
each person was asked to report the highest education level they obtained. The data that resulted
from the survey is summarized in the following table:

High School Bachelors Masters Ph.d. Total


Female 60(50.89) 54(49.87) 46(50.38) 41(49.87) 201
Male 40(49.11) 44(48.13) 53(48.62) 57(48.13) 194
Total 100 98 99 98 395

a) Null hypothesis is accepted


b) Null hypothesis is rejected
c) Both a and b
d) None of the above

19

You might also like