Algorithm Search⌘K

Theoremcore

Neyman-Pearson lemma

Also called Neyman-Pearson fundamental lemma.

For a simple null against a simple alternative, the test that rejects when the likelihood ratio exceeds a threshold is the most powerful test of its size.

The Neyman-Pearson lemma solves the simplest testing problem completely. The data come from one of two fully specified distributions, f0f_0 under the null and f1f_1 under the alternative, and the lemma says that the most powerful test at level α\alpha rejects when the likelihood ratio f1(x)/f0(x)f_1(x)/f_0(x) is above a threshold, with randomization at the threshold when the data are discrete. It also says that such a test exists for every α\alpha, and that every most powerful test has this form, except on the set where the ratio equals the threshold. It is the base of the theory of optimal tests: uniformly most powerful tests, the Karlin-Rubin theorem and unbiased tests all start from it.

Statement

Let XX take values in a set X\mathcal X, and let f0=f(⋅ ;θ0)f_0 = f(\cdot\,; \theta_0) and f1=f(⋅ ;θ1)f_1 = f(\cdot\,; \theta_1) be its densities under H0:θ=θ0H_0: \theta = \theta_0 and H1:θ=θ1H_1: \theta = \theta_1, with respect to a common measure ν\nu. For discrete data ν\nu is the counting measure and the integrals below are sums. For continuous data ν\nu is the Lebesgue measure. A common measure always exists, for example ν=P0+P1\nu = P_0 + P_1. Both hypotheses are simple: each names a single distribution.

A test is a measurable function ϕ:X→[0,1]\phi: \mathcal X \to [0, 1]. On the data xx, the test rejects H0H_0 with probability ϕ(x)\phi(x). A non-randomized test takes only the values 0 and 1. The size of ϕ\phi is E0ϕ(X)=∫ϕf0 dνE_0\phi(X) = \int \phi f_0 \, d\nu, its power is E1ϕ(X)=∫ϕf1 dνE_1\phi(X) = \int \phi f_1 \, d\nu, and ϕ\phi has level α\alpha when its size is at most α\alpha. A test is most powerful at level α\alpha when no other test of level α\alpha has more power.

Theorem (Neyman and Pearson, 1933). Let 0≤α≤10 \le \alpha \le 1.

  1. Sufficiency. Let 0≤k<∞0 \le k < \infty, and let ϕ\phi be a test with E0ϕ(X)=αE_0\phi(X) = \alpha and
ϕ(x)={1if f1(x)>kf0(x),0if f1(x)<kf0(x),\phi(x) = \begin{cases} 1 & \text{if } f_1(x) > k f_0(x), \\ 0 & \text{if } f_1(x) < k f_0(x), \end{cases}

with any value in [0,1][0, 1] on the set {f1=kf0}\{f_1 = k f_0\}. Then ϕ\phi is most powerful at level α\alpha. For α=0\alpha = 0, the test ϕ(x)=1\phi(x) = 1 if f0(x)=0f_0(x) = 0 and ϕ(x)=0\phi(x) = 0 otherwise (the case k=∞k = \infty) is also most powerful at level 0. 2. Existence. For every α\alpha there is a test of the form in part 1, with a constant value γ∈[0,1]\gamma \in [0, 1] on the set {f1=kf0}\{f_1 = k f_0\}. For α=0\alpha = 0 the test with k=∞k = \infty is allowed. 3. Necessity. Let ϕ∗\phi^* be most powerful at level α\alpha, and let ϕ\phi and kk be as in part 2. Then ϕ∗=ϕ\phi^* = \phi ν\nu-almost everywhere on the set {f1≠kf0}\{f_1 \ne k f_0\}. Also, ϕ∗\phi^* has size exactly α\alpha, unless some test of size less than α\alpha has power 1.

Corollary. Let 0<α<10 < \alpha < 1, and let β\beta be the power of the most powerful level-α\alpha test. Then α≤β\alpha \le \beta, and α<β\alpha < \beta unless P0=P1P_0 = P_1.

The ratio f1(x)/f0(x)f_1(x)/f_0(x) is the likelihood ratio L(θ1;x)/L(θ0;x)L(\theta_1; x)/L(\theta_0; x) of the likelihood function, so the test of part 1 is a likelihood ratio test in the original sense. The likelihood ratio test for composite hypotheses is a different procedure that only borrows the idea.

In plain words

Two stories could explain your data, and each story says exactly how likely every possible outcome is. You must pick the outcomes where you will reject the first story. You can afford only a fixed total chance of rejecting it when it is true, and you want the largest possible chance of rejecting it when the second story is true. Think of a budget. Each outcome costs its chance under the first story and pays its chance under the second. The best plan is to buy outcomes in the order of their pay per cost, which is the likelihood ratio, until the budget runs out. If the budget runs out in the middle of an outcome, you buy part of it by flipping a biased coin. No other plan pays more.

Proof

All integrals are with respect to ν\nu, and the argument xx is often dropped.

Part 1, sufficiency. Let ψ\psi be any test of level α\alpha, so ∫ψf0≤α\int \psi f_0 \le \alpha. We show that

(ϕ(x)−ψ(x)) (f1(x)−kf0(x))≥0for every x.(\phi(x) - \psi(x))\,(f_1(x) - k f_0(x)) \ge 0 \quad \text{for every } x.

If f1(x)>kf0(x)f_1(x) > k f_0(x), then ϕ(x)=1≥ψ(x)\phi(x) = 1 \ge \psi(x), so both factors are nonnegative. If f1(x)<kf0(x)f_1(x) < k f_0(x), then ϕ(x)=0≤ψ(x)\phi(x) = 0 \le \psi(x), so both factors are nonpositive. If f1(x)=kf0(x)f_1(x) = k f_0(x), the second factor is 0. Integrate the inequality:

∫ϕf1−∫ψf1 ≥ k(∫ϕf0−∫ψf0)=k(α−∫ψf0) ≥ 0,\int \phi f_1 - \int \psi f_1 \ \ge\ k\left(\int \phi f_0 - \int \psi f_0\right) = k\left(\alpha - \int \psi f_0\right) \ \ge\ 0,

because k≥0k \ge 0 and ∫ψf0≤α\int \psi f_0 \le \alpha. So E1ϕ≥E1ψE_1\phi \ge E_1\psi.

For the case k=∞k = \infty and α=0\alpha = 0, let ψ\psi be any test with ∫ψf0=0\int \psi f_0 = 0. Then ψ=0\psi = 0 almost everywhere on {f0>0}\{f_0 > 0\}, so ∫ψf1=∫{f0=0}ψf1≤∫{f0=0}f1=∫ϕf1\int \psi f_1 = \int_{\{f_0 = 0\}} \psi f_1 \le \int_{\{f_0 = 0\}} f_1 = \int \phi f_1.

Part 2, existence. For α=0\alpha = 0, the test with k=∞k = \infty has size ∫{f0=0}f0=0\int_{\{f_0 = 0\}} f_0 = 0. Let now 0<α≤10 < \alpha \le 1. Under P0P_0, the set {f0=0}\{f_0 = 0\} has probability 0, so the ratio R(X)=f1(X)/f0(X)R(X) = f_1(X)/f_0(X) is defined with probability 1. For c≥0c \ge 0 put

a(c)=P0(f1(X)>cf0(X))=P0(R(X)>c).a(c) = P_0(f_1(X) > c f_0(X)) = P_0(R(X) > c).

The function aa is nonincreasing and continuous from the right, because it is one minus a distribution function. By Markov's inequality, a(c)≤E0R(X)/c≤1/ca(c) \le E_0 R(X)/c \le 1/c, since E0R(X)=∫{f0>0}f1≤1E_0 R(X) = \int_{\{f_0 > 0\}} f_1 \le 1. So a(c)→0a(c) \to 0 as c→∞c \to \infty, and the number

k=inf⁡{c≥0:a(c)≤α}k = \inf\{c \ge 0 : a(c) \le \alpha\}

is finite. By right continuity, a(k)≤αa(k) \le \alpha. Next, P0(R(X)≥k)≥αP_0(R(X) \ge k) \ge \alpha: if k=0k = 0 the left side is 1, and if k>0k > 0 then a(c)>αa(c) > \alpha for each c<kc < k, and P0(R≥k)=lim⁡c↑ka(c)≥αP_0(R \ge k) = \lim_{c \uparrow k} a(c) \ge \alpha. So P0(R(X)=k)=P0(R≥k)−a(k)≥α−a(k)≥0P_0(R(X) = k) = P_0(R \ge k) - a(k) \ge \alpha - a(k) \ge 0. Put

γ=α−a(k)P0(R(X)=k) if P0(R(X)=k)>0,γ=0 otherwise.\gamma = \frac{\alpha - a(k)}{P_0(R(X) = k)} \text{ if } P_0(R(X) = k) > 0, \qquad \gamma = 0 \text{ otherwise}.

Then 0≤γ≤10 \le \gamma \le 1. Let ϕ=1\phi = 1 on {f1>kf0}\{f_1 > k f_0\}, ϕ=γ\phi = \gamma on {f1=kf0}\{f_1 = k f_0\} and ϕ=0\phi = 0 on {f1<kf0}\{f_1 < k f_0\}. The set {f0=0}\{f_0 = 0\} has P0P_0-probability 0, so

E0ϕ(X)=a(k)+γ P0(R(X)=k)=α.E_0\phi(X) = a(k) + \gamma\,P_0(R(X) = k) = \alpha.

In the second case of γ\gamma this holds because P0(R=k)=0P_0(R = k) = 0 forces a(k)=P0(R≥k)≥αa(k) = P_0(R \ge k) \ge \alpha, so a(k)=αa(k) = \alpha.

Part 3, necessity. Let ϕ∗\phi^* be most powerful at level α\alpha and let ϕ\phi, kk be the test of part 2. First take k<∞k < \infty. Let S={x:ϕ∗(x)≠ϕ(x)}∩{x:f1(x)≠kf0(x)}S = \{x : \phi^*(x) \ne \phi(x)\} \cap \{x : f_1(x) \ne k f_0(x)\}. By the case analysis of part 1, applied with ψ=ϕ∗\psi = \phi^*, the product (ϕ−ϕ∗)(f1−kf0)(\phi - \phi^*)(f_1 - k f_0) is nonnegative everywhere, and it is strictly positive on SS. If ν(S)>0\nu(S) > 0, then

∫ϕf1−∫ϕ∗f1>k(α−∫ϕ∗f0)≥0,\int \phi f_1 - \int \phi^* f_1 > k\left(\alpha - \int \phi^* f_0\right) \ge 0,

so ϕ\phi has more power than ϕ∗\phi^*, which contradicts the choice of ϕ∗\phi^*. So ν(S)=0\nu(S) = 0.

For the size, suppose E0ϕ∗<αE_0\phi^* < \alpha. Both tests are most powerful, so E1ϕ=E1ϕ∗E_1\phi = E_1\phi^*, and the integral of the nonnegative product is

0≤∫(ϕ−ϕ∗)(f1−kf0)=−k(α−E0ϕ∗).0 \le \int (\phi - \phi^*)(f_1 - k f_0) = -k\left(\alpha - E_0\phi^*\right).

This forces k=0k = 0. With k=0k = 0, ϕ=1\phi = 1 on {f1>0}\{f_1 > 0\}, so E1ϕ∗=E1ϕ=1E_1\phi^* = E_1\phi = 1, and ϕ∗\phi^* is a test of size less than α\alpha with power 1.

For k=∞k = \infty, α=0\alpha = 0 and ϕ∗\phi^* has level 0, so ϕ∗=0\phi^* = 0 almost everywhere on {f0>0}\{f_0 > 0\}, where f1<∞⋅f0f_1 < \infty \cdot f_0. On {f0=0,f1>0}\{f_0 = 0, f_1 > 0\}, if ϕ∗<1\phi^* < 1 on a set of positive ν\nu-measure, then ∫ϕ∗f1<∫ϕf1\int \phi^* f_1 < \int \phi f_1, against the choice of ϕ∗\phi^*. So ϕ∗=ϕ\phi^* = \phi almost everywhere on {f1≠kf0}\{f_1 \ne k f_0\} in this case too. □\square

Proof of the corollary. The constant test ψ≡α\psi \equiv \alpha has size α\alpha and power α\alpha, so β≥α\beta \ge \alpha. Suppose β=α\beta = \alpha. Then ψ≡α\psi \equiv \alpha is most powerful, and by part 3 it equals 0 or 1 almost everywhere on {f1≠kf0}\{f_1 \ne k f_0\}. It takes neither value, so ν(f1≠kf0)=0\nu(f_1 \ne k f_0) = 0, that is f1=kf0f_1 = k f_0 almost everywhere. Both are densities, so integration gives k=1k = 1, and then P0=P1P_0 = P_1. □\square

Consequences

  • The test depends on the data only through the likelihood ratio. If TT is a sufficient statistic, the factorization f(x;θ)=g(t(x);θ) h(x)f(x; \theta) = g(t(x); \theta)\,h(x) makes the ratio a function of t(x)t(x), so the most powerful test is a function of TT.
  • The normal mean. Let X1,…,XnX_1, \dots, X_n be iid N(μ,σ2)N(\mu, \sigma^2) with σ\sigma known, and test μ=μ0\mu = \mu_0 against μ=μ1\mu = \mu_1 with μ1>μ0\mu_1 > \mu_0. The log of the ratio is n(μ1−μ0)σ2(xˉ−μ0+μ12)\frac{n(\mu_1 - \mu_0)}{\sigma^2}\left(\bar x - \frac{\mu_0 + \mu_1}{2}\right), which increases in xˉ\bar x. So the most powerful test rejects when xˉ>c\bar x > c, and the size condition gives c=μ0+z1−ασ/nc = \mu_0 + z_{1-\alpha}\sigma/\sqrt n, with zpz_p the lower pp-quantile of N(0,1)N(0, 1). This is the one-sided z-test. With n=4n = 4, σ=1\sigma = 1, μ0=0\mu_0 = 0, μ1=1\mu_1 = 1 and α=0.05\alpha = 0.05, the test rejects when xˉ>0.8224\bar x > 0.8224, and its power is Φ(2−1.6449)=0.6388\Phi(2 - 1.6449) = 0.6388.
  • From one alternative to many. In the normal example the rejection region does not depend on μ1\mu_1, only on its sign. So the same test is most powerful against every μ1>μ0\mu_1 > \mu_0, and it is a uniformly most powerful test. The Karlin-Rubin theorem turns this observation into a theorem for families with a monotone likelihood ratio.
  • A linear program. The problem "maximize ∫ϕf1\int \phi f_1 subject to ∫ϕf0≤α\int \phi f_0 \le \alpha and 0≤ϕ≤10 \le \phi \le 1" is a linear program in ϕ\phi, a continuous knapsack problem. The lemma says that the greedy order by the ratio of value to cost is optimal, and the threshold kk is the Lagrange multiplier of the size constraint. On a finite sample space, every extreme point of the feasible set of tests with size exactly α\alpha is 0 or 1 at every point except at most one.
  • Bayes tests. With prior weights π0,π1>0\pi_0, \pi_1 > 0 on the two hypotheses, the test that minimizes π0E0ϕ+π1(1−E1ϕ)\pi_0 E_0\phi + \pi_1(1 - E_1\phi) rejects when f1/f0>π0/π1f_1/f_0 > \pi_0/\pi_1. It has the form of part 1 with k=π0/π1k = \pi_0/\pi_1, so every Bayes test is most powerful at its own size. The ratio f1/f0f_1/f_0 is the Bayes factor of two simple hypotheses.
  • Sequential and anytime tests. Wald's sequential probability ratio test applies the same ratio to data that arrive one at a time. Under H0H_0 the ratio f1(X)/f0(X)f_1(X)/f_0(X) has expectation at most 1, so it is an e-variable.
  • Generalizations. The generalized lemma (Lehmann and Romano, Theorem 3.6.1) maximizes ∫ϕfm+1\int \phi f_{m+1} subject to mm integral constraints. It gives the uniformly most powerful unbiased tests of exponential families.

Tightness

Randomization is needed for discrete data. Let XX take the values 1, 2, 3, 4 with

f0=(0.4,0.3,0.2,0.1),f1=(0.1,0.2,0.3,0.4),f_0 = (0.4, 0.3, 0.2, 0.1), \qquad f_1 = (0.1, 0.2, 0.3, 0.4),

and let α=0.25\alpha = 0.25. The ratios f1/f0f_1/f_0 are 1/4,2/3,3/2,41/4, 2/3, 3/2, 4. The most powerful test rejects at x=4x = 4 (size 0.1). The budget left is 0.150.15, so at x=3x = 3, with f0(3)=0.2f_0(3) = 0.2, it rejects with probability γ=0.15/0.2=3/4\gamma = 0.15/0.2 = 3/4. The threshold is k=3/2k = 3/2. The size is exactly 0.250.25, and the power is 0.4+34⋅0.3=0.6250.4 + \tfrac34 \cdot 0.3 = 0.625. The non-randomized tests of level 0.250.25 reject on ∅\emptyset, {3}\{3\} or {4}\{4\}, and the best of them, {4}\{4\}, has power only 0.40.4. An enumeration over the extreme points of the linear program of the previous section gives the same optimum, 5/85/8, in exact arithmetic. A non-randomized test of the form of part 1 is most powerful only at its own size, which here is one of the attainable values 0,0.1,0.3,0.6,10, 0.1, 0.3, 0.6, 1.

The set where the ratio equals kk. Part 3 says nothing about ϕ∗\phi^* on {f1=kf0}\{f_1 = k f_0\}, and it cannot. In the example above, any test that rejects at x=4x = 4 and spends 0.150.15 of size at x=3x = 3 is most powerful. If two points tie at the threshold, the size left can be split between them in any proportion.

Simple hypotheses only. The proof uses one density for each hypothesis. Against the two-sided alternative μ≠μ0\mu \ne \mu_0 of the normal example, the most powerful test against μ1>μ0\mu_1 > \mu_0 rejects for large xˉ\bar x, and the most powerful test against μ1<μ0\mu_1 < \mu_0 rejects for small xˉ\bar x. No single test is most powerful against both, so no uniformly most powerful test exists. For a composite null, the lemma applies to a least favorable distribution on the null (Lehmann and Romano, Chapter 3), which is not always easy to find.

The power can equal the size. The corollary needs P0≠P1P_0 \ne P_1. If the two distributions are equal, every test has power equal to its size, and the data carry no information.

History

Neyman and Pearson introduced the likelihood ratio criterion in 1928, as a principle for choosing a test. In their 1933 paper "On the problem of the most efficient tests of statistical hypotheses", they posed the problem of the best critical region of given size for a simple hypothesis against a simple alternative, and they proved that the region where the ratio of the two likelihoods exceeds a constant is the solution. They also showed that the same region can be best against a whole class of alternatives, which led to the uniformly most powerful tests. The statement used today, with randomized tests and with the three parts of existence, sufficiency and necessity, is the one of Lehmann's book Testing Statistical Hypotheses (1959). Dantzig and Wald (1951) gave the measure-theoretic form of the generalized lemma, and the connection with linear programming made it a standard example of duality.

References

  1. George Casella and Roger L. Berger, Statistical Inference, second edition, Duxbury, 2002, Section 8.3.2, Theorem 8.3.12 (the Neyman-Pearson lemma) and the corollary after it (the form in terms of a sufficient statistic)
  2. E. L. Lehmann and Joseph P. Romano, Testing Statistical Hypotheses, third edition, Springer, 2005, Section 3.2, Theorem 3.2.1 (existence, sufficiency and necessity, with randomized tests) and Corollary 3.2.1 (the power exceeds the size); Section 3.6, Theorem 3.6.1 (the generalized lemma)
  3. Jerzy Neyman and Egon S. Pearson, On the problem of the most efficient tests of statistical hypotheses, Philosophical Transactions of the Royal Society of London, Series A 231 (1933), pages 289 to 337, the most efficient critical region for a simple hypothesis against a simple alternative

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/8G9YHV/text.yaml