An alpha region is a tail area of a reference distribution containing the probability assigned to the rejection rule. In a two-tailed test, the alpha regions sit beyond the critical range. A test statistic landing there provides enough evidence to reject the null hypothesis; landing inside the range means failing to reject it. section 6.6
Checking a potato-chip weight claim
For a claimed mean weight of 142 grams, a 5% significance level leaves 95% in the center of the standard normal distribution and places the rejection areas in both tails. The critical Z-values are about -1.96 and 1.96. A sample Z-value of -2.4062 falls in an alpha region, so the claim is rejected. section 6.6
from math import sqrt #1
from scipy.stats import norm #1
mu = 142.0 #2
n = 41 #3
x_bar = 140.2 #4
s = 4.79 #5
alpha = 0.05 #6
z_stat = (x_bar - mu) / (s / sqrt(n)) #7
critical_z = norm.ppf(1 - (alpha / 2)) #8
print("Population mean: ", mu) #9
print("Sample mean: ", x_bar) #9
print("Sample standard deviation: ", s) #9
print("Sample size: ", n) #9
print("Level of confidence: ", 1 - alpha) #9
print("Level of significance: ", alpha) #9
print("z-statistic: ", z_stat) #9
print("Critical value: ", critical_z) #9
if -critical_z <= z_stat <= critical_z: #10
print("Decision: Fail to reject the null hypothesis. "
"The sample does not provide enough evidence the mean is different.") #11
else:
print("Decision: Reject the null hypothesis. "
"The sample provides enough evidence the mean is different.") #11
"""
Population mean: 142.0
Sample mean: 140.2
Sample standard deviation: 4.79
Sample size: 41
Level of confidence: 0.95
Level of significance: 0.05
z-statistic: -2.4061844733568267
Critical value: 1.959963984540054
Decision: Reject the null hypothesis. The sample provides enough evidence the
mean is different
"""
Experiment with the significance level, sample mean, standard deviation, and sample size, then observe how the test statistic and decision change. section 6.6
