Session 6: Hypothesis Testing
A dairy company suspects that some suppliers are adding water to their milk. This can be detected by checking the freezing point of the milk.
The freezing temperature of natural milk is normally distributed, with
mean = -0.52°C
standard deviation = 0.01°C
Added water raises the freezing temperature towards 0°C, the freezing point of water.
A random sample of 16 lots produces the sample mean of -0.514°C.
Question: Are the suppliers honest?
Calculate the probability of getting a sample mean of -0.51 or larger:
In this example:
\(\mu = -0.52\)
\(\sigma = 0.01\)
\(\bar{X} = -0.514\)
\(n = 16\)
SE = \(\sigma_{\bar{X}} = \sigma/\sqrt{n} = 0.01/4= 0.0025\)
We call the probability of getting a sample mean that far from the prescribed population mean or even further as p-value.
\[\begin{aligned} \mathbb{P}(\bar{X} > -0.514) & = \mathbb{P}( \frac{\bar{X} - \mu}{SE} > \frac{-0.514 - \mu}{SE}) \\ &= \mathbb{P}( Z > \frac{-0.514 - (-0.52)}{0.0025}) \\ &= \mathbb{P}( Z > 2.4) \\ &= 0.0082 \end{aligned}\]
\(\mathbb{P}(\bar{X} > -0.514) = 0.0082\)
The probability that we get this worse sample mean just due to the sampling (we’re so unlucky) is very small
For a normal distribution, lower than 5% (or less) can be considered an "unlikely" case (can be ignored)
However, something unlikely to happen, but it indeed happened
It is very likely that the null hypothesis (\(H_0\)) is incorrect (contradiction)
in favour of the alternative hypothesis, defendant guilty!
Hypothesis testing can be used to determine whether a statement about the value of a population parameter should or should not be rejected.
The null hypothesis, denoted by \(H_0\), is a tentative assumption about a population parameter.
The alternative hypothesis, denoted by \(H_1\), is the opposite of what is stated in the null hypothesis.
The alternative hypothesis is often what the test is attempting to establish (one side or two sides).
Another key concept in hypothesis testing: significance level, denoted as \(\alpha\).
In reality, the event with a small probability can still happen:
The hypothesis is true, but due to ignoring the chance of extreme events happening, we incorrectly reject the hypothesis.
The hypothesis is false, but due to ignoring the chance of extreme events happening, we incorrectly accept the hypothesis.
Both errors can happen:
The error in the first scenario is called a Type I error, denoted as alpha, which is what we refer to as the significance level (\(\alpha\)).
The error in the second scenario is called a Type II error, generally denoted as \(\beta\).
In the case of a Type 1 error, we are considering whether the sample data occurs in the extreme cases within the assumed population. If the answer is ‘YES’, it means that the original hypothesis is correct, but after all our hard work, we happen to fall into the situation where an error occurs, leading to an incorrect conclusion.
In the case of a Type 2 error, we are considering whether the sample data happens to be included when the population hypothesis is incorrect. If the answer is ‘YES’, it means that the original hypothesis is wrong, but due to an unfortunate coincidence, this error is supported by the information calculated from the sample data, leading us to make an incorrect conclusion.
Type I error: \(\mathbb{P}(\text{Reject } H_0 | H_0 \text{ True}) = \alpha\)
Type II error: \(\mathbb{P}(\text{Accept } H_0 | H_0 \text{ False}) = \beta\)

Note: this is a one-talied test, since the rejection region occupies only one side of the distribution
Step 1: Develop the null and alternative hypotheses (upper or lower or two sides!). For example, testing for mean:
Step 2: Specify the level of significance \(\alpha\) and the test statistic
Step 3: Collect the sample data and compute the test statistic
Then we have two approaches to making decisions:
Step 4: Use the value of the test statistic to compute the p-value
Step 5: Reject \(H_0\) if p-value \(\leq \alpha\) (one side) or Reject \(H_0\) if p-value \(\leq \alpha/2\) (two sides)
The smaller the p-value, the more evidence there is against \(H_0\)
A small p-value indicates the value of the test statistic is unusual given the assumption that \(H_0\) is true.
Step 4: Use the level of significance (\(\alpha\)) to determine the critical value and the rejection rule.
Step 5. Use the value of the test statistic and the rejection rule to determine whether to reject \(H_0\).
Lower tail: Reject \(H_0\) if \(z \leq -z_{\alpha}\)
Upper tail: Reject \(H_0\) if \(z \geq z_{\alpha}\)
Two tails: Reject \(H_0\) if \(z \geq z_{\alpha/2}\) or \(z \leq -z_{\alpha/2}\)
Role: Risk Analyst at a bank
Objective: Evaluate the impact of a new credit approval system on the average loan approval time.
Historical Average: \(5\) days
Known Standard Deviation: \(1.5\) days
Sample Data: \(36\) loan applications
Sample Mean: \(4.7\) days

Null Hypothesis (\(H_0\)): \(\mu = 5\) (No change in average approval time)
Alternative Hypothesis (\(H_1\)): \(\mu \neq 5\) (Change in average approval time)
Choose a significance level (\(\alpha\)) of \(5\%\).
Using Z-statistic (known population standard deviation): \[Z = \frac{( \bar{x} - \mu )}{\frac{\sigma}{\sqrt{n}}}\]
\(\bar{x} = 4.7\), \(\mu = 5\), \(\sigma = 1.5\), \(n = 36\) \[Z = \frac{( 4.7 - 5 )}{\frac{1.5}{\sqrt{36}}} = -1.2\]
The p-value for \(Z = -1.2\) is approximately \(0.23\)
\(p > \alpha\) (\(0.23 > 0.05\))
Fail to reject \(H_0\)
Insufficient evidence to conclude that the average loan approval time has changed.
Critical Z-value for \(\alpha = 0.05\) in a two-tailed test: \(\pm 1.96\)
Calculated \(Z = -1.2\) doesn’t fall in the critical region \((-\infty, -1.96) \cup (1.96, \infty)\)
Fail to reject \(H_0\)
Insufficient evidence to conclude that the average loan approval time has changed.
Role: Risk Analyst at a bank
Objective: Evaluate the impact of a new credit approval system on the average loan approval time.
Historical Average: \(5\) days
Known Standard Deviation: \(1.5\) days
Sample Data: \(36\) loan applications
Sample Mean: \(4.7\) days
Now, our question is to check if the new credit approval system reduces the approval time.
Null Hypothesis (\(H_0\)): \(\mu \geq 5\) (No reduction in average approval time)
Alternative Hypothesis (\(H_1\)): \(\mu < 5\) (Reduction in average approval time)
Choose a significance level (\(\alpha\)) of \(0.05\).
Using Z-statistic (known population standard deviation): \[Z = \frac{( \bar{x} - \mu )}{\frac{\sigma}{\sqrt{n}}}\]
\(\bar{x} = 4.7\), \(\mu = 5\), \(\sigma = 1.5\), \(n = 36\) \[Z = \frac{( 4.7 - 5 )}{\frac{1.5}{\sqrt{36}}} = -1.2\]
P-Value Approach:
The p-value for \(Z = -1.2\) is approximately \(0.115\)
\(p > \alpha\) (\(0.115 > 0.05\))
Fail to reject \(H_0\)
Critical Value Approach:
Critical Z-value for \(\alpha = 0.05\) in a one-tailed test: \(-1.645\)
Calculated \(Z = -1.2\) is greater than \(-1.645\)
Fail to reject \(H_0\)
Therefore, insufficient evidence to conclude that the average loan approval time has been reduced.
Role: Risk Analyst at a bank
Objective: Evaluate if the new credit approval system reduces the average loan approval time.
Historical Average: \(5\) days
Sample Data: \(36\) loan applications
Sample Mean: \(4.7\) days
Sample Standard Deviation: \(1.5\) days
Null Hypothesis (\(H_0\)): \(\mu \geq 5\) (No reduction in average approval time)
Alternative Hypothesis (\(H_1\)): \(\mu < 5\) (Reduction in average approval time)
Choose a significance level (\(\alpha\)) of \(0.05\).
Using t-statistic (unknown population standard deviation): \[t = \frac{( \bar{x} - \mu )}{\frac{s}{\sqrt{n}}}\]
\(\bar{x} = 4.7\), \(\mu = 5\), \(s = 1.5\), \(n = 36\) \[t = \frac{( 4.7 - 5 )}{\frac{1.5}{\sqrt{36}}} = -1.2\]
Critical Value Approach:
Degrees of Freedom = \(n - 1 = 35\)
Critical t-value for \(\alpha = 0.05\) and \(35\) df: \(-1.689\)
Calculated \(t = -1.2\) is greater than \(-1.689\)
Fail to reject \(H_0\)
P-Value Approach:
The p-value for \(t = -1.2\) and \(35\) df is approximately \(0.12\)
\(p > \alpha\) (\(0.12 > 0.05\))
Fail to reject \(H_0\)
Therefore, insufficient evidence to conclude that the average loan approval time has reduced.
In terms of population mean (both estimator and test),
If \(\sigma\) is unknown, you need to use t-distribution to make an inference
Since t-distribution with a degree of freedom greater than 30 is already quite similar to a normal distribution, we can also just use the normal distribution to make inferences in the cases (unknown \(\sigma\))
Direction: Area of Concerns
Clue Words: Faster, Improving, Slower, Getting Worse, Recession, Fall in Trade etc.
Hints:
IF there is a Direction/ Area of concern, then ONE-TAIL(ONE-SIDE)
If NOT, then TWO-TAIL (TWO-SIDE)
Historical proportion of satisfied customers: \(p = 0.7\)
After one year of hard work on customer satisfaction, we have
Sample proportion of satisfied customers (\(\hat{p}\)): \(0.75\)
Sample size (\(n\)): \(100\)

Null Hypothesis \(H_0\): \(p \leq 0.7\) (no positive change)
Alternative Hypothesis \(H_1\): \(p > 0.7\)
Choose a significance level (\(\alpha\)) of \(0.05\).
Recap: \[z = \frac{\hat{p} - p}{\sqrt{\frac{p(1-p)}{n}}}\] Did you still remember the conditions?
np > 5 or 10
n(1-p) > 5 or 10
\(\hat{p} = 0.75\), \(p = 0.7\), \(n = 100\)
\(z = \frac{0.75 - 0.7}{\sqrt{\frac{0.7 \times 0.3}{100}}} = 1.16\)
Critical Value Approach:
Critical z-value for \(\alpha = 0.05\): \(z = 1.645\)
Calculated \(z = 1.16\) is less than \(1.645\)
Fail to reject \(H_0\)
P-Value Approach:
The p-value for \(z = 1.16\) is approximately \(0.12\)
\(p > \alpha\) (\(0.12 > 0.05\))
Fail to reject \(H_0\)
Therefore, insufficient evidence to conclude that the proportion of satisfied customers has positively increased.
To reject the null hypothesis, what is the minimum sampling proportion we have to observe? \[z = \frac{\hat{p} - 0.7}{\sqrt{\frac{0.7 \times 0.3}{100}}} > 1.645\]
Therefore: \[\hat{p} > 0.775\]
Data (usually assuming it is a sample from a population)
Sample size \(n\)
Population assumption (normal or not, known standard deviation or not, etc)
What statistic do we focus? (sample mean or simple proportion? or others)
Formulate the hypotheses
Null hypothesis (usually, equal, no difference, no increase, no reduction, etc)
Alternative hypothesis (deciding one-side or two-side)
Calculate the given statistic:
z-statistic
t-statistic
etc
Inference approaches given significant level \(\alpha\):
Critical value approach: compare \(z_{\alpha}\) or \(z_{\alpha/2}\) with \(\alpha\) or \(\alpha/2\)
P-Value Approach: calculate the p-value for the given statistic, and compare it with \(\alpha\)
Reject \(H_0\) if test statistic is in rejection region and draw conclusion
p-value is very small (e.g., p-value <0.05 )
statistic is very large ( e.g, statistic > 1.645 )
| Aspect | Confidence Interval | Hypothesis Test |
|---|---|---|
| Objective | To estimate a population parameter within a certain range | To test a specific claim or hypothesis about a parameter |
| Result | Provides a range for the parameter | Yields a p-value (critical value) |
| Interpretation | Describes the uncertainty associated with a sampling method | Compares p-value to a predetermined significance level (critical value) |
| One-Sided or Two-Sided | Usually two-sided | Can be one-sided or two-sided |
| Decision Making | More informative, provides a range of plausible values | Provides a definite yes-or-no answer |
We can use confidence interval approach to test a hypothesis

In some cases, we need to know both Type I and II errors because we need to take the corresponding actions!
Scenario II: Check if the new credit approval system reduces the approval time.
Historical Average: \(5\) days, Known Standard Deviation: \(1.5\) days, Sample Data: \(36\) loan applications, Sample Mean: \(4.7\) days
Null Hypothesis (\(H_0\)): \(\mu \geq 5\) (No reduction in average approval time)
Alternative Hypothesis (\(H_1\)): \(\mu < 5\) (Reduction in average approval time)
Let’s look at error:
Type I Error (\(\alpha\)): Rejecting \(H_0\) when it is actually true.
Type II Error (\(\beta\)): Not rejecting \(H_0\) when \(H_1\) is true.
Scenario: Checking if the new credit system reduces the approval time.
\(H_0: \mu \geq 5\), \(H_1: \mu < 5\)
Sample size \(n = 36\), sample mean \(\bar{x} = 4.7\), \(\sigma = 1.5\), =\(1.5/\sqrt{36} = 0.25\)
Test Statistic \(Z = (4.7 - 5) / SE = -1.2\), p-value = 0.115
\(\alpha = 0.05\), thus \(z_{\alpha} = -1.645\)
So the threshold is \(5 - 1.645 \times 0.25 = 4.58875\)
Assuming the true average is now indeed 4.8, \[\beta = \mathbb{P}(X > 4.58875 | \mu = 4.8 ) =\mathbb{P}(X > \frac{4.58875 - 4.8}{SE} = - 0.845) = 0.80\]
\(\alpha\) is the tolerance threshold for Type I error
p-value \(= 0.115 > 0.05 = \alpha\)
\(\beta\) is the Type II error given a known true fact (\(H_0\) is incorrect)
Test power (\(1-\beta\)), or "power", is the probability of correctly rejecting a false null hypothesis.
Scenario II: Check if the new credit approval system reduces the approval time.
Null Hypothesis (\(H_0\)): \(\mu \geq 5\) (No reduction in average approval time)
Alternative Hypothesis (\(H_1\)): \(\mu < 5\) (Reduction in average approval time)
According to our test result (from \(\alpha\), essential)
Insufficient evidence to conclude that the average loan approval time has been reduced (due to p-value > \(\alpha\)).
The probability that the bank thinks the new system is better, when it’s not is very low (less than \(\alpha\))
According to our test result (from \(\beta\), optional), assuming the truth of mean is 4.8 days
0.3 Risk-Averse
Smaller \(\alpha\)
Minimise Type I
Increases \(\beta\)
Conservative
0.35 Risk-Seeking
Higher \(\alpha\)
Risk of Type I
Reduces \(\beta\)
High Test Power
0.35 Risk-Neutral
\(\alpha = 0.05\)
Balanced Errors
Test Power \(\geq 0.8\)
Scientific Use
Hypothesis
Formulate Hypothesis
One-side or two-side
Significance level
Inference approach and rejection region
Critical value
p-value
Test Statistic
Sample mean, known \(\sigma\) and unknown \(\sigma\)
Sample proportion
etc
Further issues (optional)
Confidence interval approach to do test
Type I and Type II error
