A null hypothesis is the status-quo claim that a statistical test starts by assuming. It usually says that nothing unusual is happening: a population mean matches an advertised value, a treatment has no effect, or two variables have no linear correlation. It is written H0. section 6.0 section 6.15
The point is not to prove H0 true. Sample results naturally vary, so a difference from the claim may be chance noise. A test asks whether the observed result would be unusually unlikely if H0 were true. Strong enough evidence leads to rejecting H0; otherwise, the decision is to fail to reject it, not to declare it proven. section 6.1 section 6.15
Are chip bags really 142 grams?
For a two-tailed check of an advertised mean, set H0: μ = 142 and Ha: μ ≠ 142. A sample mean of 140.2 g alone does not settle the question: individual bags and samples vary. The test combines the claimed mean, sample mean, standard deviation, sample size, and significance level to decide whether the difference is sufficiently surprising under H0. section 6.6
Write H0 and its alternative as mutually exclusive opposites before looking at the result:
- For any-direction mean differences, use equality in H0 and not-equals in Ha: H0: μ = 142; Ha: μ ≠ 142. section 6.6
- For a directional “less than” question, include equality on the null side: H0: μ ≥ 142; Ha: μ < 142. Choosing a direction limits what the test investigates. section 6.8
- For Pearson correlation, use H0: r = 0 for no linear correlation and Ha: r ≠ 0 for a linear relationship. section 7.3
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
"""
This short SciPy calculation turns a chip-bag sample into a z-statistic, critical value, and a reject-or-fail-to-reject decision for H0. section 6.6



