Neyman–Pearson testing and power
Build a most-powerful simple-hypothesis test and calculate exact size, randomization, and power.
On this page
The question for today
What you’ll understand
- Distinguish size, power, and posterior probability.
- Prove the likelihood-ratio ordering for simple hypotheses.
- Calibrate a discrete test with optional boundary randomization.
A test is a decision rule whose error probabilities can be evaluated before seeing the data. The Neyman–Pearson problem asks which rule detects one specified alternative most often while keeping false rejections under a chosen null probability. It is a constrained optimization problem, not a rule that attaches a posterior probability to a hypothesis. Working through a tiny binary experiment makes the distinction visible: you can enumerate every outcome, decide where to spend the false-rejection budget, and calculate exactly what power that budget buys.
Specify the two laws and the error budget
For simple hypotheses, both and are completely specified probability laws. A test function is the probability of rejecting after observing ; values strictly between zero and one represent a separate random decision. Its size here is , and its power against the specified alternative is . A level- rule satisfies size at most . For a composite null, level requires control at every law in that null, a different optimization problem.
The two errors play different roles: false rejection is constrained, and failure to reject under the alternative is reduced by maximizing power. Neither probability is the chance that the null is true after observing the data. A failure to reject may reflect low power rather than agreement with the null. Planning sample size therefore requires specifying alternatives or effect sizes worth detecting. An error budget alone does not tell you whether an experiment can reliably resolve the scientific question.
Spend the budget where the likelihood ratio is largest
Assume the two laws have densities with respect to a common measure. Choose a nonnegative threshold and let reject where , accept where , and randomize as needed on equality so that its size equals . Outcomes possible only under the alternative can be rejected without spending null probability. The Neyman–Pearson lemma says this rule has at least as much power as every level- competitor. This is a finite-sample result with no normal approximation.
The proof is an ordering argument. At each outcome, is nonnegative by construction. Integrating shows that the power difference is at least times the size difference, which is nonnegative because the chosen rule uses the full budget and the competitor cannot exceed it. This demonstrates optimality for the specified simple alternative. A single rule need not be most powerful for every alternative in a two-sided composite problem, where opposite changes can favor opposite tails.
Discrete outcomes leave gaps in attainable sizes
For a binomial count, null tail probabilities jump in discrete increments. A deterministic cutoff may use less than the available error budget. Randomizing at one boundary count fills the gap exactly: divide the remaining budget by the null probability of that count. This is a mathematically valid decision rule, though some applications prefer a conservative nonrandomized test for reproducibility. The chosen convention should be specified in advance rather than changed after seeing the outcome.
A p-value is a calibrated tail measure derived from a specified test ordering, not the probability of the null and not generally the probability of the observed outcome alone. Discrete p-values are often conservative under the null. Changing the sampling rule, selecting the best-looking test after inspection, or repeatedly testing until a rejection can change the false-rejection probability. The finite-sample calculations below assume the declared fixed sample size, iid Bernoulli model, and one prespecified test.
Work it through
Use exactly a tenth of null probability
For , test against at size . Construct the likelihood-ratio test and calculate its exact power.
The likelihood ratio is , increasing by a factor three for each extra success. Thus spend the error budget on the largest counts first.
Under the null, and . Reject at four and randomize with probability at three; otherwise do not reject.
Under the alternative, and . Power is .
The test has exact size 0.1 and power 0.3796875. The substantial chance of nonrejection under the alternative illustrates limited information in four trials.
The living notebook
Explore the model
Interactive lab · probability
Read size and power from exact bars
Reset, set both , and predict bar-four mass and bar-three mass . Combine all of bar four with 15% of bar three on paper. Reset and set both to calculate power with the same rule. The lab displays exact count masses; it does not perform the extra boundary randomization.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forOne fixed rejection rule has different probabilities under the null and alternative laws.
Pause & reason
Check your understanding
Your turn
Try it yourself
For two iid Bernoulli trials, test against at level . Find a most-powerful nonrandomized rule and its exact power.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Order the three possible counts by their likelihood ratio, and calculate the null probability of the largest count.
Compare with the solution
The likelihood ratio increases with the count. Reject only at , whose null probability is , so the full budget is used without randomization. Power is . The Neyman–Pearson ordering proves this rule is most powerful even among randomized level- tests.
Keep the idea
Take it with you
- Size is false rejection under the null; power is rejection under a specified alternative.
- Likelihood-ratio ordering solves the simple-versus-simple problem exactly.
- Discrete calibration may require boundary randomization or a conservative size.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.