Hypothesis testing: p-values, errors, and power
A null hypothesis, a test statistic, a rejection region — and the two ways a test can be wrong.
You change a model, the metric moves, and a dashboard says "significant". But metrics move for no reason all the time. Hypothesis testing is the machinery for asking whether an observed effect is larger than what chance alone would produce, and the discipline of stating in advance how surprised you would need to be.
Assume nothing happened, then measure the surprise
Testing starts by assuming the boring world — the null hypothesis, no effect. Under that assumption the test statistic has a known distribution, so we can ask how unusual the observed value is. The answer is the p-value. If it is small enough, the null looks like a bad explanation of the data.
Set the observed sample mean, the standard error, and α below. The shaded regions are where the null would be rejected; the marker is where the data actually fell.
A z-test under the null — where does the observation fall, and how much tail is beyond it?
- z
- 1.600
- p-value
- 0.1096
- critical z
- 1.960
- decision
- fail to reject H₀
Amber is the rejection region under H₀: α/2 in each tail. The accent band is the two-tailed p-value for the observed z.
The p-value is the probability, assuming H₀, of a result at least as extreme as the one observed — here it is the tail area beyond z. Shrinking the standard error (more data) pushes z out and the p-value down, which is why statistical significance is partly a statement about sample size. It is not the probability that H₀ is true.
The machinery
A test has five ingredients:
- Null hypothesis — the default, usually "no effect" (§).
- Alternative hypothesis — what you would conclude if is rejected (two-sided, or one-sided).
- Test statistic — a number computed from the data whose distribution under is known. For a sample mean this is the z-score .
- Significance level — the false-positive rate you are willing to tolerate, chosen before seeing the data.
- Decision rule — reject when the statistic falls in the rejection region, equivalently when the p-value is below .
The p-value is the probability, computed under , of obtaining a statistic at least as extreme as the one observed. For a two-sided z-test that is twice the tail area beyond .
The two errors
Every decision can go wrong in two ways:
- Type I error: rejecting a true . Its probability is exactly , the significance level.
- Type II error: failing to reject a false , with probability . The power of the test is — the chance it detects an effect that is really there.
Power rises with the size of the true effect, with the sample size, and with ; it falls with the variability of the data. A test with low power will fail to detect real effects and is the reason "not significant" is so often misread as "no effect".
What a p-value is not
A p-value is not the probability that is true, and is not the probability that the effect is real. It is . Conflating the two is the most common misinterpretation in applied work: a small p-value says the data would be surprising under the null, not that the null is probably false. It also says nothing about the size of the effect.
Tests and intervals
A two-sided test at level is equivalent to checking whether the null value lies in a confidence interval for the parameter: reject exactly when the interval excludes it. Confidence intervals are usually more informative, because they show the range of plausible effect sizes rather than a single yes-or-no verdict. Report them alongside p-values.
Illustrative vs real
The widget runs a clean one-sample z-test with a known standard error and a normal null distribution. Real studies have small samples with heavy tails (hence t-tests), multiple comparisons that inflate the family-wise error rate, and optional stopping that quietly invalidates the nominal . The logic is the same; the guarantees are only as good as the assumptions.
Check yourself
Eduspheria wiki · Mathematics for AI, Statistics
0 / 5 answered
From the exam paper
Modeled on NITJ AI-501, End-Sem December 2024
0 / 5 answered
Where next: with linear algebra and probability in hand, you have the mathematical foundation for the machine-learning domains.