core30 min studyLesson 247 in Mathematics

Neyman–Pearson testing and power

Build a most-powerful simple-hypothesis test and calculate exact size, randomization, and power.

On this page

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 P0P_0 and P1P_1 are completely specified probability laws. A test function ϕ(x)∈[0,1]\phi(x)\in[0,1] is the probability of rejecting after observing xx; values strictly between zero and one represent a separate random decision. Its size here is E0ϕE_0\phi, and its power against the specified alternative is E1ϕE_1\phi. A level-α\alpha rule satisfies size at most α\alpha. 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.

sup⁡0≤ϕ≤1 E1[ϕ(X)]subject toE0[ϕ(X)]≤α\sup_{0\le\phi\le1}\ E_1[\phi(X)]\quad\text{subject to}\quad E_0[\phi(X)]\le\alpha
For two specified laws, the Neyman–Pearson problem maximizes detection probability under a false-rejection constraint.↔ Scroll wide equations horizontally.

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 cc and let ϕ∗\phi^* reject where f1>cf0f_1>cf_0, accept where f1<cf0f_1<cf_0, and randomize as needed on equality so that its size equals α\alpha. 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-α\alpha competitor. This is a finite-sample result with no normal approximation.

The proof is an ordering argument. At each outcome, (ϕ∗−ϕ)(f1−cf0)(\phi^*-\phi)(f_1-cf_0) is nonnegative by construction. Integrating shows that the power difference is at least cc 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.

E1(ϕ∗−ϕ)=∫(ϕ∗−ϕ)(f1−cf0) dν+cE0(ϕ∗−ϕ)≥0E_1(\phi^*-\phi)=\int(\phi^*-\phi)(f_1-cf_0)\,d\nu+cE_0(\phi^*-\phi)\ge0
The pointwise ordering makes the first term nonnegative, and equal calibrated size alpha versus a level-alpha competitor makes the second term nonnegative.↔ Scroll wide equations horizontally.

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.

Use exactly a tenth of null probability

For K∼Binomial⁡(4,p)K\sim\operatorname{Binomial}(4,p), test p=0.5p=0.5 against p=0.75p=0.75 at size 0.10.1. Construct the likelihood-ratio test and calculate its exact power.

  1. The likelihood ratio is (0.75/0.5)K(0.25/0.5)4−K(0.75/0.5)^K(0.25/0.5)^{4-K}, increasing by a factor three for each extra success. Thus spend the error budget on the largest counts first.

  2. Under the null, P(K=4)=1/16=0.0625P(K=4)=1/16=0.0625 and P(K=3)=4/16=0.25P(K=3)=4/16=0.25. Reject at four and randomize with probability (0.1−0.0625)/0.25=0.15(0.1-0.0625)/0.25=0.15 at three; otherwise do not reject.

  3. Under the alternative, P(K=4)=0.754=0.31640625P(K=4)=0.75^4=0.31640625 and P(K=3)=4(0.75)3(0.25)=0.421875P(K=3)=4(0.75)^3(0.25)=0.421875. Power is 0.31640625+0.15(0.421875)=0.37968750.31640625+0.15(0.421875)=0.3796875.

The result

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.

Explore the model

Interactive lab

Interactive lab · probability

Read size and power from exact bars

Reset, set both p=0.5,n=4p=0.5,n=4, and predict bar-four mass 0.06250.0625 and bar-three mass 0.250.25. Combine all of bar four with 15% of bar three on paper. Reset and set both p=0.75,n=4p=0.75,n=4 to calculate power with the same rule. The lab displays exact count masses; it does not perform the extra boundary randomization.

Read size and power from exact barsThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

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.

Check your understanding

For simple null and alternative laws with an available boundary randomization, where does a most-powerful level-α test allocate rejection probability first?

Try it yourself

For two iid Bernoulli trials, test p=0.5p=0.5 against p=0.75p=0.75 at level 0.250.25. 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 K=2K=2, whose null probability is (0.5)2=0.25(0.5)^2=0.25, so the full budget is used without randomization. Power is (0.75)2=0.5625(0.75)^2=0.5625. The Neyman–Pearson ordering proves this rule is most powerful even among randomized level-0.250.25 tests.

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.