from edumath.statistics import one_sample_z_test, z_test_statistic
z_test_statistic(105, 100, 2.5)2.0
A hypothesis test asks whether observed data are surprising under a baseline claim. Tests do not prove truth. They organize evidence, probability, and a pre-chosen decision rule.
After this lesson you should be able to:
A hypothesis test begins by temporarily assuming the null hypothesis is true. Then it asks:
If the null hypothesis were true, how unusual would our data be?
If the data would be very unusual under the null, we have evidence against the null.
The null hypothesis H0 is the baseline claim. It often says no effect, no difference, or a known value.
The alternative hypothesis Ha is what we look for evidence toward. It can be two-sided or one-sided.
Examples:
H0: mu = 100
Ha: mu != 100
H0: p = 0.50
Ha: p > 0.50
A test statistic measures how far the estimate is from the null value in standard error units.
z = (estimate - null value) / standard error
A large positive or negative statistic means the estimate is far from the null value relative to expected sampling variability.
A p-value is the probability, assuming the null hypothesis is true, of obtaining a result at least as extreme as the observed one.
A p-value is not:
The significance level alpha is chosen before the test, often 0.05.
Decision rule:
if p-value <= alpha: reject H0
if p-value > alpha: fail to reject H0
“Fail to reject” does not mean “prove the null.” It means the data did not provide strong enough evidence against the null using that test and alpha.
| Decision | Reality | Error? |
|---|---|---|
reject H0 |
H0 true |
Type I error |
fail to reject H0 |
H0 false |
Type II error |
A Type I error is a false positive. A Type II error is a false negative.
A process is supposed to have mean 100. A random sample gives mean 105, and the standard error is 2.5. Test whether the mean is greater than 100.
Step 1: State hypotheses.
H0: mu = 100
Ha: mu > 100
Step 2: Compute the z statistic.
z = (105 - 100) / 2.5
z = 5 / 2.5
z = 2
Step 3: Interpret.
The sample mean is 2 standard errors above the null value.
Step 4: Use a p-value.
For a greater-than test, z=2 gives p-value about 0.023.
Step 5: Make a decision at alpha 0.05.
Since 0.023 <= 0.05, reject H0.
Conclusion: The data provide evidence that the process mean is greater than 100, assuming the test conditions are appropriate.
A test gives p-value 0.18.
Incorrect interpretation: There is an 18% chance the null is true.
Correct interpretation: If the null hypothesis were true, results this extreme or more extreme would happen about 18% of the time. That is not very surprising, so at alpha 0.05 we fail to reject the null.
A huge study finds a treatment improves average score by 0.2 points with p-value 0.001.
The result is statistically significant, but the effect may be too small to matter in practice. Always ask:
How large is the effect in real units?
50.z when estimate is 42, null value is 40, and standard error is 1.0.05, what decision is made for p-value 0.03?0.05, what decision is made for p-value 0.20?H0: mu = 50; Ha: mu != 50.z=(42-40)/1=2.H0.H0.Guess first. If the question says “has increased,” is the alternative usually > or !=?
Guided exercise.
“Increased” is directional, so the alternative is usually >.
Checkpoint. Write the alternative for “the mean is less than 20.”
Guess first. If an estimate is exactly equal to the null value, what is the z statistic?
Guided exercise.
z = (estimate - null) / SE = 0 / SE = 0
Checkpoint. Compute z for estimate 12, null 10, and SE=4.
Guess first. Is a smaller p-value stronger or weaker evidence against H0?
Guided exercise.
Smaller p-values mean the observed result is more surprising under H0, so they are stronger evidence against H0.
Checkpoint. At alpha 0.01, is p-value 0.03 significant?
Guess first. Is a false positive Type I or Type II?
Guided exercise.
A false positive means rejecting a true null hypothesis. That is Type I error.
Checkpoint. What kind of error is failing to reject a false null?
Ha: mu < 20.z=(12-10)/4=0.5.0.03 > 0.01, so fail to reject at alpha 0.01.Use edumath for z statistics and normal-approximation p-values.
2.0
HypothesisTestResult(statistic=2.0, p_value=0.02275013194817921, alternative='greater')
Use SymPy to rearrange the z-statistic formula.