Hypothesis Testing in Engineering
Hypothesis Testing in Engineering
& STATISTICS
• Note that:
𝑃 Reject 𝐻$ when 𝐻$ is wrong + 𝑃 Reject 𝐻$ when 𝐻$ is true ≠ 100%
Hypothesis testing’s general procedure
1. Pick the null hypothesis 𝐻! . It could be one-sided or two-sided.
2. Find the optimal test statistic.
3. Pick a significance level and find the rejection region.
4. Compare the value of the test statistic from the data with the
rejection region.
5. Make the conclusion.
Tests Concerning Mean of a
Normal Population
Example
• We know that the heights of Vietnamese men have been improved
in the last 30 years. We want to check whether the average height
of the population has been reached to 170cm or not.
• We take a sample and perform hypothesis testing. The two types
of hypotheses can be written down as:
H! : 𝜇 = 170
H" : 𝜇 ≠ 170
Two-sided test for known variance (𝑧-test) (1)
• Assume that our data is a random sample that 𝑋! , 𝑋" , …, 𝑋$ are IID
normal distributed with unknown mean 𝜇 and a known variance 𝜎 " .
• Under H% : 𝜇 = 𝜇% , the distribution 𝑁(𝜇% , 𝜎 " ) generates the data. Hence,
𝑋! + 𝑋" + ⋯ + 𝑋# 𝜎"
𝑋0 = ~ 𝑁(𝜇% , )
𝑛 𝑛
• We get the test statistic as:
𝑋0 − 𝜇%
𝑍= ~ 𝑁(0,1)
𝜎/ 𝑛
𝝈𝟐
- ~ 𝑵(𝝁𝟎 , )
𝑿
𝒏
0
Two-sided test for known variance (𝑧-test) (3)
• Let choose a significance 𝛼, we get the rejection region (or the critical
region) in the blue-shaded areas as:
𝜶 𝜶
𝟐 𝟐
0
Rejection Non-rejection Rejection
region of 𝑯𝟎 region of 𝐻# region of 𝑯𝟎
Critical values
Critical values for significance level 𝜶
• Critical values are like quantiles except
they refer to the probability to the right
of the value instead of the left at 𝛼. 𝜶 𝜶
𝟐
• The value of the test statistic that marks 0
𝟐
−𝟏. 𝟗𝟔 0 𝟏. 𝟗𝟔
Rejection Rejection
region of 𝑯𝟎 region of 𝑯𝟎
Example
• 𝑧 = 2.167 belong to the rejection region.
• Hence, we can reject 𝐻! that the mean of the Vietnamese men’s
height is 170cm.
• It implies that we have evidence for 𝐻" that the mean of the
Vietnamese young men’s height is NOT 170cm.
Example
If we use the significance level at 1%, what is outcome of the test?
Solution:
• The new critical values is 𝑧!.!!0 = 2.580. Now, 𝑧 = 2.167 do not
belong to the rejection region.
• Hence, we cannot reject the null hypothesis. Hence, this
evidence is supporting 𝐻!
Example
Now, we have another sample, with 𝑛 = 1000 and 𝑥̅ = 168.7. Perform
the test at the significance at 1% and 5%?
Solution:
• The new test statistic is:
𝑥̅ − 𝜇% 168.8 − 170
𝑧= = ≈ −6.852
𝜎/ 𝑛 6 ∗ 1000
• It is a huge value. We can reject the null hypothesis at 1% and 5%
significance levels..
One-sided test for known variance
• In the one-sided test, the null hypothesis involves a range of
values rather a single value as in the one-sided test.
• We have two types of two-sided test:
H! : 𝜇 ≥ 𝜇! 𝑣𝑠 H" : 𝜇 < 𝜇!
H! : 𝜇 ≤ 𝜇! 𝑣𝑠 H" : 𝜇 > 𝜇!
• Note that for technical reasons, 𝑯𝟎 must always have ≥ or ≤ or =
One-sided test for known variance (2)
• For one-sided tests, the test statistic, under the null hypothesis
𝐻! , is also the same:
𝑋h − 𝜇!
𝑍= ~ 𝑁(0, 1)
𝜎/ 𝑛
• The rejection region now changes. At a significance level 𝛼:
For H! : 𝜇 ≥ 𝜇! 𝑣𝑠 H" : 𝜇 < 𝜇! : it is [−∞, 𝑧1 ]
For H! : 𝜇 ≤ 𝜇! 𝑣𝑠 H" : 𝜇 > 𝜇! : it is [ 𝑧1 , +∞]
Two-side 𝑯𝟎 : 𝝁 ≠ 𝝁𝟎
𝛼/2 𝛼/2
−𝑧$/& 𝑧$/&
𝑧' −𝑧'
• The conclusion:
With samples #1 and #2, we fail to reject 𝐻$, and
We can reject 𝐻$ with sample #3.
The critical values for the 𝒛 test
One-sided One-sided
Significance Two-sided
Left-tail Right-tail
level 𝜶
Critical Values
• Note: you can obtain them from the table of the standard normal CDF, or
using the function NORM.DIST()of Excel.
𝑝-value
• Definition: Assume the null hypothesis, 𝒑-value is the
probability of the obtaining the test statistic (from experimental
data) is at least as extreme as from observed data.
• In other words, 𝑝-value is the smallest significance level that we
can reject 𝐻! with the data.
• In practice, people often specify the significance level and
perform the significance test using 𝑝-values.
Computing 𝒑-value
• The 𝑝-value is the total probability computed
from the obtained test statistic. 0
The test statistic 𝒙
-
• The orange-shaded region is “at least as (obtained from the data)
extreme as” the data.
• One-sided and two-sided tests have a slightly
𝜶
different way to compute the 𝑝-value. 𝟐
• We can reject the null hypothesis when the
orange-shaded area is than the blue-shaded 0
The test statistic 𝒙
-
area. (obtained from the data)
Example: 𝒑-value of a one-sided test
• For example, if we have a
negative statistic 𝑧 = −2.37 for a
𝜶
one-sided z test. 𝟐
The area of p-value Non-rejection
• From 𝑃 𝑍 ≤ −2.37 = 0.009, the region of 𝐻#
𝜶 𝜶
The area of The area of 𝟐
𝟐 p-value
p-value
Non-rejection Non-rejection
region of 𝐻# region of 𝐻#
0 0
Rejection Rejection
region of 𝑯𝟎 region of 𝑯𝟎
Example: 𝒑-value of a two-sided test
• For example, if we have a negative
statistic 𝑧 = −2.37 for a two-sided
𝜶
𝒛 test. The area of p-value 𝟐 The area of p-value
Non-rejection
• From 𝑃 𝑍 ≤ −2.37 = 0.009, the p- region of 𝐻#
value is 2 ∗ 0.009 = 0.018 or 1.8% 0
• We can reject the null hypothesis
Rejection Rejection
at 1% significance level but do not region of 𝑯𝟎 region of 𝑯𝟎
reject at 5%.
Problem
A population distribution is known to have standard deviation
𝜎 = 20. Determine the 𝑝-value of a test of the hypothesis that the
population mean is equal to 50, if the average 𝑋h of a sample of 64
observations is:
a. 52.5
b. 55.0
c. 57.5.
Unknown Variance:
the 𝑡-test
𝟐
Hypothesis testing under unknown 𝝈
• The case of known 𝜎 " is rare.
• The more common situation is that both 𝝁 and 𝝈𝟐 are unknown.
• Under that case, we need to perform the 𝑡-test.
• It is noted that we are still assuming that the population is normally
distribution.
The set-up of 𝒕 test
• We have a random sample 𝑋! , 𝑋" , … , 𝑋# ~ 𝑁 𝜇, 𝜎 " with unknown 𝜇 and 𝜎 " .
• The hypothesis can be one-sided or two-sided.
• Under the null hypothesis 𝐻$, the test statistic has a Student-𝑡 distribution:
𝑋` − 𝜇$
𝑇= ~ 𝑡D@E
𝑆/ 𝑛
𝑡D@E has 𝑛 − 1 degrees of freedom.
The set-up of 𝒕 test (2)
• With a data, we can compute the value of the test statistic as:
𝑥̅ − 𝜇!
𝑇=
𝑆/ 𝑛
"
where 𝑆 =8 ∑9;<" 𝑥; − 𝑥̅ 8
as the sample variance.
9:"
The Student-𝑡 distribution
Two-side 𝑯𝟎 : 𝝁 ≠ 𝝁𝟎
−𝑡'/) 𝑡'/)
• The rejection regions are similar
to the 𝑧 test. One-side: 𝑯𝟎 : 𝝁 ≥ 𝝁𝟎 𝐯𝐬 𝑯𝟏 : 𝝁 < 𝝁𝟎
𝑋h − 𝑌h − Δ
𝑡= ~ 𝑁(0, 1)
𝜎>8 𝜎B8
𝑛 +𝑚
The rejection region
• Two-sided:𝐻" : 𝜇> − 𝜇B ≠ Δ
−∞, −𝑧1/8 ∪ 𝑧1/8 , +∞
• One-sided 𝐻" : 𝜇> − 𝜇B > Δ (greater)
𝑧1 , +∞
• One-sided 𝐻" : 𝜇> − 𝜇B < Δ (lesser)
−∞, −𝑧1
Equality of two means: Normal and
UNKNOWN and EQUAL variance
• Two groups of data are normal random samples:
𝑋; ∼ 𝑁 𝜇> , 𝜎>8 , 𝑖 = 1,2, … 𝑛
𝑌A ∼ 𝑁(𝜇B , 𝜎B8 ), 𝑗 = 1,2, … 𝑚
where both 𝜇> and 𝜇B are unknown and possibly different.
• 𝜎>8 , 𝜎B8 are UNKNOWN but EQUAL.
• 𝑋; and 𝑌A are assumed to be independent.
The test statistic
= B:?
>: = ! :?#
• From @$"
~ 𝑡9ED:8 , the test statistic:
𝑋h − 𝑌h − Δ
𝑡= 8 ~ 𝑡(𝑛 + 𝑚 − 2)
𝑆F
" "
9:" G! E D:" G# " "
with 𝑆F8 = + ; 𝑆> and 𝑆B are the sample
9ED:8 9 D
mean of two random sample 𝑋; and 𝑌A
The rejection region
• Two-sided 𝐻" : 𝜇> − 𝜇B ≠ Δ
−∞, −𝑡1,/8 9ED:8 ∪ 𝑧1,/8 9ED:8 , +∞
𝑋h − 𝑌h − Δ
𝑍= ≈ 𝑁(0, 1)
𝑆>8 𝑆B8
+
𝑛 𝑚
Normal Population: Summary (3)
The paired 𝑡 –test
Data in pairs
• When the data naturally comes in pairs (𝑥0 , 𝑦0 ), we can use the paired
two-sample 𝑡-test.
• ‘The pair’ is roughly thought as two measurements taken from the
same individual, object, or related units before and after an effect.
• Example: the body’s weights of a group of participants before and after an
exercise-training program; or
Fuel consumption of a group of cars after an engine upgrade.
𝐻# : 𝜎'& = 𝜎(&
𝐻) : 𝜎(& ≠ 𝜎(&