Search

Search papers and lessons

Neyman–Pearson Lemma

Level 3 · 14 min read

The Neyman–Pearson lemma says that for two fully specified hypotheses, the test that rejects when the likelihood ratio is large is the most powerful test at any chosen false-alarm rate.

On this page

  • Colour = topic mix
  • Probability
  • Inference
  • Discrete math
  • Calculus
  • Sampling
  • ReadReady to readNot yet

TL;DR

Suppose you must choose between two fully specified claims about how data are produced, and you accept a fixed chance of a false alarm. The Neyman–Pearson lemma says the best rule is to reject the default claim whenever the data are much more likely under the rival claim than under the default, measured by the likelihood ratio. No other rule with the same false-alarm rate catches more real effects.

Builds on: Null Hypothesis, Type I Error, Type II Error, Likelihood Function, Log-Likelihood Ratio, Probability Density Function · Leads to: Statistical Power, Wald Test, Bayes Factor

Where it's used

Radar and signal detection. A radar receiver must decide whether an echo is a real aircraft or only background noise. Each possibility gives the received signal a different probability distribution, so the receiver can compute how much more likely each echo is under "aircraft present" than under "noise only." The receiver sets a false-alarm rate it can live with, and the lemma tells it which threshold on the ratio gives the highest detection rate at that rate.

Particle physics searches. When physicists look for a new particle, they compare a model with the particle against a model without it. The data are binned counts, and each bin has a probability under each model. The 2012 Higgs boson discovery at CERN rested on likelihood-ratio test statistics, which are the same idea extended to models with unknown nuisance parameters.

Manufacturing and quality checks. A line is known to produce a certain rate of defects when it is running well. An engineer asks whether a new, higher rate is present. Counting defects over a fixed time gives a clean pair of fully specified models, so the lemma gives the best counting rule for a given false-stop rate. The worked examples below use this setting.

How it works

Here is a tiny case with one observation. A box holds a single draw XX (a Random Variable) that can be 1, 2 or 3. There are two claims about the box:

  • H0H_0 (the default): the draw has probabilities P(1)=0.6P(1) = 0.6, P(2)=0.3P(2) = 0.3, P(3)=0.1P(3) = 0.1.
  • H1H_1 (the rival): the draw has probabilities P(1)=0.2P(1) = 0.2, P(2)=0.3P(2) = 0.3, P(3)=0.5P(3) = 0.5.

We may reject H0H_0 only so often that the false-alarm rate, the chance of rejecting when H0H_0 is true, is at most α=0.10\alpha = 0.10.

  1. Write down both claims in full. Each one gives a probability to every outcome. Check: each list adds to 1. 0.6+0.3+0.1=10.6 + 0.3 + 0.1 = 1 and 0.2+0.3+0.5=10.2 + 0.3 + 0.5 = 1.
  2. For each outcome, compute the likelihood ratio. This is the probability under the rival divided by the probability under the default. Outcome 1 gives 0.2/0.6=1/30.2 / 0.6 = 1/3. Outcome 2 gives 0.3/0.3=10.3 / 0.3 = 1. Outcome 3 gives 0.5/0.1=50.5 / 0.1 = 5. Check: a ratio above 1 means the outcome favours the rival.
  3. Sort the outcomes from largest ratio to smallest. The order is 3, then 2, then 1. Check: the ratios are 55, 11, 1/31/3, in that order.
  4. Add outcomes to the rejection set in that order, while the false-alarm rate stays within α\alpha. Start with outcome 3. Under H0H_0 its chance is 0.10.1, which is exactly α\alpha, so we keep it. Adding outcome 2 would raise the false-alarm rate to 0.1+0.3=0.40.1 + 0.3 = 0.4, which is too much, so we stop. Check: the rejection set is {3}\{3\} and its false-alarm rate is 0.100.10.
  5. Measure the power. Power is the chance of rejecting when H1H_1 is true. Under H1H_1, outcome 3 has chance 0.50.5. Check: power =0.5= 0.5.
  6. Compare with a sensible alternative. Suppose we rejected outcome 2 only some of the time, with probability 1/31/3. Its false-alarm chance under H0H_0 is then 0.3×1/3=0.10.3 \times 1/3 = 0.1, which fits the level. Its power is 0.3×1/3=0.10.3 \times 1/3 = 0.1, far below 0.50.5. Check: the same false-alarm budget buys five times more power when spent on outcome 3.

The idea behind step 4 is the important part. Each unit of false-alarm budget spent on an outcome buys power in proportion to how much more likely that outcome is under the rival. The ratio is exactly that exchange rate, so spending the budget on the highest ratios first is the best you can do.

flowchart LR
  A[Write H0 and H1 in full] --> B[Likelihood ratio for each outcome]
  B --> C[Sort outcomes by ratio, largest first]
  C --> D[Add outcomes while false-alarm rate is within alpha]
  D --> E[Reject H0 on the chosen set]

The plot below shows the same idea for a continuous measurement. Two normal curves describe the default claim (centre 0) and the rival claim (centre 1). The rule "reject when the measurement is large" is the likelihood-ratio rule, because for these two curves the ratio grows as the measurement grows.

−3−2−10123400.10.20.30.40.5measurement xdensity
  • H0: centre 0
  • H1: centre 1
For two normal curves with equal spread, the likelihood ratio increases with x, so the best rule rejects when x is large enough.

The math

Definition: Simple hypotheses and the likelihood ratio

Let XX be the data. Under H0H_0 its density (or mass function) is f0(x)f_0(x), and under H1H_1 it is f1(x)f_1(x). Both claims are fully specified, so neither has unknown parameters. The likelihood ratio is Λ(x)=f1(x)f0(x),f0(x)>0.\Lambda(x) = \frac{f_1(x)}{f_0(x)}, \qquad f_0(x) \gt 0. A test is a rule φ(x)\varphi(x) with values between 0 and 1: φ(x)\varphi(x) is the chance of rejecting H0H_0 after seeing xx.

Step 1 in symbols: the two rates

The false-alarm rate (size) and the detection rate (power) of a test φ\varphi are averages of φ\varphi under each claim: αφ=E0[φ(X)]=∫φ(x) f0(x) dx,βφ=E1[φ(X)]=∫φ(x) f1(x) dx.\alpha_\varphi = \mathbb{E}_0[\varphi(X)] = \int \varphi(x)\, f_0(x)\, dx, \qquad \beta_\varphi = \mathbb{E}_1[\varphi(X)] = \int \varphi(x)\, f_1(x)\, dx. In the box example, φ\varphi is 1 on outcome 3 and 0 elsewhere, so αφ=P0(3)=0.1\alpha_\varphi = P_0(3) = 0.1 and βφ=P1(3)=0.5\beta_\varphi = P_1(3) = 0.5. In words: α\alpha is the Type I Error rate and β\beta is the Statistical Power.

Step 2 in symbols: ranking by the ratio

Fix a threshold k≥0k \ge 0 and define the likelihood-ratio test φ∗\varphi^* by φ∗(x)={1if Λ(x)>k,γif Λ(x)=k,0if Λ(x)<k,\varphi^*(x) = \begin{cases} 1 & \text{if } \Lambda(x) \gt k, \\ \gamma & \text{if } \Lambda(x) = k, \\ 0 & \text{if } \Lambda(x) \lt k, \end{cases} where γ∈[0,1]\gamma \in [0,1] is used only on the boundary Λ(x)=k\Lambda(x) = k, and only when it is needed. In the box example, any kk between 1 and 5, say k=4k = 4, gives φ∗=1\varphi^* = 1 on outcome 3 only, with no boundary case. Taking the logarithm turns the ratio into a sum, which is the Log-Likelihood Ratio form that is often easier to work with.

Step 3 in symbols: fitting the level

Choose kk and γ\gamma so that αφ∗=α\alpha_{\varphi^*} = \alpha. In the box example, k=4k = 4 gives exactly α=0.1\alpha = 0.1, and γ\gamma is not needed. For a continuous model, γ\gamma is not needed and kk is the upper α\alpha point of the distribution of Λ\Lambda under H0H_0. For a discrete model, the exact level may need a randomised boundary, as in the Poisson example below.

Step 4 in symbols: no test does better

Lemma. If φ\varphi is any test with αφ≤αφ∗\alpha_\varphi \le \alpha_{\varphi^*}, then βφ≤βφ∗\beta_\varphi \le \beta_{\varphi^*}.

Proof. Consider the difference (φ∗(x)−φ(x)) (f1(x)−k f0(x))(\varphi^*(x) - \varphi(x))\,(f_1(x) - k\,f_0(x)) at a single point xx.

  • Where Λ(x)>k\Lambda(x) \gt k, we have f1(x)>kf0(x)f_1(x) \gt k f_0(x), so the second factor is positive. Also φ∗(x)=1≥φ(x)\varphi^*(x) = 1 \ge \varphi(x), so the first factor is nonnegative.
  • Where Λ(x)<k\Lambda(x) \lt k, the second factor is negative and φ∗(x)=0≤φ(x)\varphi^*(x) = 0 \le \varphi(x), so the first factor is nonpositive.
  • Where Λ(x)=k\Lambda(x) = k, the second factor is zero.

So the product is nonnegative at every xx. Integrate it over all xx: ∫(φ∗−φ) f1 dx  −  k∫(φ∗−φ) f0 dx  ≥  0,\int (\varphi^* - \varphi)\, f_1\, dx \;-\; k \int (\varphi^* - \varphi)\, f_0\, dx \;\ge\; 0, which says βφ∗−βφ≥k (αφ∗−αφ)\beta_{\varphi^*} - \beta_\varphi \ge k\,(\alpha_{\varphi^*} - \alpha_\varphi). The right side is at least zero, because k≥0k \ge 0 and αφ∗≥αφ\alpha_{\varphi^*} \ge \alpha_\varphi. Hence βφ∗≥βφ\beta_{\varphi^*} \ge \beta_\varphi. ■\blacksquare

The proof uses only the sign of f1−kf0f_1 - k f_0, which is why the same argument works for discrete and continuous data.

Worked examples

Example
Example 1: two coin flips (tiny)

Claims: H0H_0 says the coin is fair, so the chance of heads is p=1/2p = 1/2. H1H_1 says the coin lands heads with chance p=3/4p = 3/4. We flip twice and let XX be the number of heads. The allowed false-alarm rate is α=0.25\alpha = 0.25.

  1. Under H0H_0, the chances are P0(0)=1/4P_0(0) = 1/4, P0(1)=1/2P_0(1) = 1/2, P0(2)=1/4P_0(2) = 1/4. Check: they add to 1.
  2. Under H1H_1, the chances are P1(0)=1/16P_1(0) = 1/16, P1(1)=6/16P_1(1) = 6/16, P1(2)=9/16P_1(2) = 9/16. Check: 1+6+9=161 + 6 + 9 = 16.
  3. Ratios: Λ(0)=(1/16)/(1/4)=1/4\Lambda(0) = (1/16)/(1/4) = 1/4, Λ(1)=(6/16)/(1/2)=3/4\Lambda(1) = (6/16)/(1/2) = 3/4, Λ(2)=(9/16)/(1/4)=9/4\Lambda(2) = (9/16)/(1/4) = 9/4.
  4. Largest ratio first: reject on 2 heads. Its false-alarm chance is P0(2)=1/4=0.25P_0(2) = 1/4 = 0.25, which fits the level. Adding 1 head would raise it to 3/43/4, too much.
  5. Power of this test is P1(2)=9/16=0.5625P_1(2) = 9/16 = 0.5625.
  6. Compare the test "reject on 0 heads". Its false-alarm chance is 1/41/4, the same level, but its power is P1(0)=1/16=0.0625P_1(0) = 1/16 = 0.0625.

The lemma says the first test is the best of all tests at this level. Here the comparison is easy to check by hand.

Example
Example 2: the standard case, one-sided test on a mean

A sensor reports the average of n=25n = 25 independent readings. Each reading is normal with spread 1. H0H_0 says the true mean is μ0=0\mu_0 = 0; H1H_1 says it is μ1=0.5\mu_1 = 0.5. We want a test at level α=0.05\alpha = 0.05.

  1. The sample mean Xˉ\bar{X} is normal with mean μ\mu and spread 1/25=0.21/\sqrt{25} = 0.2.
  2. The log-likelihood ratio is log⁡Λ=nμ1Xˉ−nμ12/2−(nμ0Xˉ−nμ02/2)\log \Lambda = n\mu_1 \bar{X} - n\mu_1^2/2 - (n\mu_0 \bar{X} - n\mu_0^2/2). With μ0=0\mu_0 = 0 this is 25×0.5×Xˉ−25×0.25/2=12.5 Xˉ−3.12525 \times 0.5 \times \bar{X} - 25 \times 0.25 / 2 = 12.5\,\bar{X} - 3.125.
  3. The ratio increases with Xˉ\bar{X}, so the best rule rejects when Xˉ\bar{X} is large: reject when Xˉ≥c\bar{X} \ge c.
  4. Under H0H_0, Xˉ\bar{X} has spread 0.20.2, so the 5 percent point is c=1.645×0.2=0.329c = 1.645 \times 0.2 = 0.329.
  5. Power: under H1H_1, Xˉ\bar{X} has mean 0.50.5. The chance Xˉ≥0.329\bar{X} \ge 0.329 is P(Z≥(0.329−0.5)/0.2)=P(Z≥−0.855)P(Z \ge (0.329 - 0.5)/0.2) = P(Z \ge -0.855), where ZZ is a standard normal variable.
  6. P(Z≥−0.855)=Φ(0.855)≈0.80P(Z \ge -0.855) = \Phi(0.855) \approx 0.80, where Φ\Phi is the standard normal distribution function.

So the test detects a true shift of half a unit about 80 percent of the time, with a 5 percent false-alarm rate. The Gaussian (Normal) Distribution tells us why the cutoff is a simple multiple of the spread.

Example
Example 3: a realistic defect count

A line is known to produce defects at an average rate of 2 per hour when it is running well. The engineer suspects the rate has risen to 4 per hour. Let XX be the number of defects in one hour. Under each claim XX follows a Poisson Distribution. We allow a false-stop rate of about 0.017.

  1. Under H0H_0 (rate 2), P(X=k)=e−22k/k!P(X = k) = e^{-2} 2^k / k!. Under H1H_1 (rate 4), P(X=k)=e−44k/k!P(X = k) = e^{-4} 4^k / k!.
  2. The ratio is Λ(k)=e−22k\Lambda(k) = e^{-2} 2^k. Check: the factor k!k! cancels, and e−4/e−2=e−2e^{-4}/e^{-2} = e^{-2}. This ratio increases with kk.
  3. So the best rule rejects on large counts: reject when X≥cX \ge c.
  4. Under H0H_0, P(X≥6)≈0.0166P(X \ge 6) \approx 0.0166 and P(X≥5)≈0.0527P(X \ge 5) \approx 0.0527. The first fits the level 0.017, so c=6c = 6.
  5. Under H1H_1 (rate 4), the power is P(X≥6)=1−P(X≤5)P(X \ge 6) = 1 - P(X \le 5). Summing the terms e−4(1+4+8+10.67+10.67+8.53)e^{-4}(1 + 4 + 8 + 10.67 + 10.67 + 8.53) gives P(X≤5)≈0.785P(X \le 5) \approx 0.785.
  6. So the power is 1−0.785=0.2151 - 0.785 = 0.215. The engineer catches a doubled defect rate about one hour in five.

This is not a bad test for a small false-alarm budget, but it is weak. The lemma says no other rule at level 0.017 does better.

Try it: the engineer relaxes the false-alarm rate to α=0.0527\alpha = 0.0527, so the rule becomes X≥5X \ge 5. What is the power under rate 4? Answer: P(X≥5)=1−P(X≤4)=1−e−4(1+4+8+10.67+10.67)=1−0.629≈0.37P(X \ge 5) = 1 - P(X \le 4) = 1 - e^{-4}(1 + 4 + 8 + 10.67 + 10.67) = 1 - 0.629 \approx 0.37. A larger false-alarm budget buys more power, at the price of more false stops.

Common mistakes and tradeoffs

It is tempting to think that the likelihood ratio is the probability that H1H_1 is true. In fact Λ(x)\Lambda(x) compares how well the two claims predict the data, and it says nothing about how plausible each claim is before the data arrive. Turning it into a probability of the claim requires a prior, which is the territory of Bayes Factor and Bayesian updating.

It is tempting to think that a larger power always means a better test. In fact power is only meaningful at a fixed false-alarm rate. Raising α\alpha always raises power, so the level has to be chosen from the cost of false alarms, and the lemma then tells you the best rule for that choice.

It is tempting to think that the lemma covers any alternative. In fact it compares two simple claims, each with every parameter fixed. When the alternative is a range of values (for example "the mean is greater than 0"), the best test can change with the value, and the lemma does not apply directly. Some families, such as the normal mean in Example 2, still have a single best one-sided test, but that is a separate result.

It is tempting to think that the best test always uses the most data. In fact the lemma depends on the full likelihood. A simpler summary, such as the sample mean in Example 2, can be just as powerful if it keeps all the information the ratio needs.

When to use it. Use the likelihood-ratio rule when both claims are fully specified, you care about one kind of error, and you want the highest power at a stated false-alarm rate. It is the standard benchmark for detection problems.

When not to use it. Do not use it when the alternative contains unknown parameters that the test cannot fix in advance, when the costs of the two errors are known and should drive the decision (use decision theory instead), or when the model itself may be wrong. In those cases alternatives include the Wald Test, which approximates the ratio using estimates, and Bayesian decision rules.

History

In the 1920s Ronald Fisher's significance testing used a single null claim and a P-Value, with no explicit rival. Jerzy Neyman and Egon Pearson began working together in the late 1920s and asked a sharper question: which test is best when there is a specific alternative to detect?

Their answer appeared in 1933 in a paper in the Philosophical Transactions of the Royal Society. The key result, the lemma, showed that the ratio of likelihoods gives the best test for two simple claims. Abraham Wald later generalised the idea into a full theory of statistical decisions in the 1940s and 1950s, which made the lemma a building block of modern testing. It caught on because it gives a single clear recipe, and because the same recipe appears in radar, communication and physics.

Recap

  • A hypothesis test is a rule for rejecting a default claim H0H_0, judged by two rates: the false-alarm rate α\alpha and the power β\beta.
  • For two fully specified claims, the likelihood ratio Λ(x)=f1(x)/f0(x)\Lambda(x) = f_1(x)/f_0(x) says how much each outcome favours the rival.
  • Spending the false-alarm budget on the largest ratios first gives the most power at that level.
  • The Neyman–Pearson lemma proves that no other test with the same or smaller false-alarm rate has more power.
  • Read next: Statistical Power for the power side, Wald Test when the claims have unknown parameters, and Bayes Factor for comparing claims with priors.

Check yourself

QuestionIn one sentence, what does the Neyman–Pearson lemma say about the likelihood-ratio test?Show answer
It says that among all tests whose false-alarm rate is at most α\alpha, the likelihood-ratio test has the largest power, so no other rule at that level detects the rival claim more often.
QuestionIn the box example, outcome 1 has P0=0.6P_0 = 0.6 and P1=0.2P_1 = 0.2. Outcome 3 has P0=0.1P_0 = 0.1 and P1=0.5P_1 = 0.5. At level α=0.40\alpha = 0.40, which outcomes should the rule reject, and what is its power?Show answer
Sort by ratio: outcome 3 has ratio 5 and outcome 2 has ratio 1. Rejecting {3, 2} has false-alarm rate 0.1+0.3=0.40.1 + 0.3 = 0.4, which fits the level. Adding outcome 1 would exceed it. The power is P1(3)+P1(2)=0.5+0.3=0.8P_1(3) + P_1(2) = 0.5 + 0.3 = 0.8.
QuestionWhy does ranking outcomes by the likelihood ratio, rather than by their probability under H1H_1, give the best rule?Show answer
The false-alarm budget is limited, so what matters is power gained per unit of false-alarm chance. The ratio P1(x)/P0(x)P_1(x)/P_0(x) is exactly that exchange rate. An outcome can have a large P1P_1 and still be a poor choice if it is also very likely under H0H_0.
QuestionA radar receiver must keep its false-alarm rate at 1 percent. Explain in plain words how it should set its rule, and why the rule is still optimal even when real aircraft are rare.Show answer
It should compute the likelihood ratio of each echo under aircraft present versus noise only, and reject when the ratio exceeds the threshold whose noise-only probability is 1 percent. The rule is optimal at that false-alarm rate because the lemma compares rules only on detection rate and false-alarm rate, not on how common aircraft are. Rarity matters for the overall error rate and must be handled by a prior, which the lemma does not include.

Sources