---
title: Detection and estimation theory
heading: Deciding between hypotheses with the likelihood ratio, Bayes costs and the MAP rule, the Neyman–Pearson criterion and the ROC, sufficient statistics from many samples, photon-counting detection, and maximum-likelihood estimation against the Cramér–Rao bound
eyebrow: S8 · Lesson 12 · Detection and estimation theory
xp: 50
---

::: hook
A radar must decide, from one noisy echo sample, whether a target is there. A digital receiver must decide whether a bit was 0 or 1. An optical receiver counts a handful of photons and must decide whether its laser was on. They're all the same problem, and Van Trees solves it once: compute how much more likely the observation is under one hypothesis than the other, and compare that ratio with a threshold that depends on what you know and what mistakes cost. The matched filter and every error-rate formula in the lessons that follow come out of it.
:::

::: play
- One observation r is noise alone (H₀, mean 0) or a signal plus noise (H₁, mean d), with unit-variance Gaussian noise, so d is the signal-to-noise distance.
- The curves are the two probability densities. The receiver decides H₁ when r exceeds the threshold γ (the marker).
- The readouts give the false-alarm probability (the H₀ density's area above γ), the detection probability (the H₁ density's area above γ), and the overall error probability when both hypotheses are equally likely, which is smallest at γ = d/2.
:::

```sim plot
view: graph
x: r = -4..8
y: p = 0..0.45
slider: d = 0..6 = 2.5
slider: g = -2..6 = 1.25
plot: exp(-r^2/2)/sqrt(2*pi) | samples: 400 | label: H₀: noise
plot: exp(-(r - d)^2/2)/sqrt(2*pi) | samples: 400 | color: ch3 | label: H₁: signal + noise
marker: r = g
readout: false alarm P_F = Q(g) | digits: 4
readout: detection P_D = Q(g - d) | digits: 4
readout: error probability, equal priors = (Q(g) + 1 - Q(g - d))/2 | digits: 4
```

::: predict
## Ones are sent 90% of the time and zeros 10%, as 1 V and 0 V in Gaussian noise of σ = 1 V. Where should the minimum-error threshold sit?

- [ ] At 0.5 V, halfway
- [ ] Above 0.5 V, to protect the rare zeros
- [x] Below 0.5 V, toward the zero level
- [ ] At 1 V

::: reveal
The MAP rule compares the likelihood ratio with $P_0/P_1$ = 1/9. For Gaussian noise that puts the threshold at $m/2 + (\sigma^2/m)\ln(P_0/P_1)$ = 0.5 − 2.2 = −1.7 V: with ones so common and noise this large, the receiver should call almost everything a one. Prior probabilities move the threshold toward the less likely signal.
:::
:::

::: nameit
## The likelihood ratio test

Given an observation r with density $p(r|H_0)$ or $p(r|H_1)$, every optimal decision rule has the same form:

$$\Lambda(r) = \frac{p(r|H_1)}{p(r|H_0)} \ \underset{H_0}{\overset{H_1}{\gtrless}}\ \eta$$

Only the threshold η depends on the criterion:

- **Bayes** (minimum average cost, with costs $C_{ij}$ for deciding $H_i$ when $H_j$ is true): $\eta = \dfrac{P_0(C_{10} - C_{00})}{P_1(C_{01} - C_{11})}$.
- **Minimum probability of error (MAP)**: equal costs for both errors, so $\eta = P_0/P_1$; with equal priors, η = 1, the **maximum-likelihood** rule.
- **Neyman–Pearson**: when priors and costs are unknown, maximize $P_D$ subject to $P_F \le \alpha$; η is whatever makes $P_F = \alpha$.

The **receiver operating characteristic** plots $P_D$ against $P_F$ as η varies; every criterion picks a point on it.

## Gaussian observations

For a mean of 0 or m in Gaussian noise of variance σ², the log likelihood ratio is linear in r, and the test becomes a threshold on r itself:

$$r \ \underset{H_0}{\overset{H_1}{\gtrless}}\ \gamma = \frac m2 + \frac{\sigma^2}{m}\ln\eta$$

Then $P_F = Q(\gamma/\sigma)$ and $P_D = Q(\gamma/\sigma - d)$, with $d = m/\sigma$. With equal priors the error probability is $Q(d/2)$. For N independent samples, their sum is a **sufficient statistic**: it carries all the information, and d grows to $m\sqrt N/\sigma$. For a waveform, the same reasoning gives the correlator and matched filter of lesson 13.

## Photon counting

An optical receiver counts photons, which arrive as Poisson events: mean $m_0$ (dark counts and background) or $m_1$ (laser on). The likelihood ratio grows with the count, so the test is "decide H₁ if $n \ge k$," with $P_F$ and $P_D$ given by Poisson tail sums. Because counts are integers, only certain $(P_F, P_D)$ pairs are available without randomizing.

## Estimation

To estimate a parameter θ from observations, the **maximum-likelihood** estimate maximizes $p(r|\theta)$. No unbiased estimator can beat the **Cramér–Rao bound**:

$$\operatorname{var}(\hat\theta) \ge \frac{1}{I(\theta)}, \qquad I(\theta) = E\left[\left(\frac{\partial\ln p(r|\theta)}{\partial\theta}\right)^2\right]$$

For a constant level in N independent Gaussian samples, $I = N/\sigma^2$, and the sample mean, which is the ML estimate, has variance exactly $\sigma^2/N$: it's **efficient**. Synchronizers (lesson 22) are estimators of phase and timing, judged against the same bound.
:::

::: example
## A target's echo gives d = 4 (in units of σ). With the false-alarm probability held to 10⁻³, what's the detection probability, and how many independent looks would equal priors need for 1% error?

::: solution
1. **Threshold.** $P_F = Q(\gamma/\sigma)$ = 10⁻³ puts the threshold at
   $$\gamma = 3.09\sigma$$
2. **Detection probability.**
   $$\begin{aligned} P_D &= Q(3.09 - 4) \\ &= Q(-0.91) \\ &= 0.82 \end{aligned}$$
   A single look misses almost one target in five.
3. **Distance for 1% error.** With equal priors the error probability is $Q(d_N/2)$, and 1% needs $d_N/2$ = 2.33:
   $$d_N = 4.65$$
4. **Number of looks.** Since $d_N = d\sqrt N$, a target with d = 2 per look needs
   $$\begin{aligned} N &= \left(\frac{4.65}{2}\right)^2 \\ &= 5.4 \end{aligned}$$
   so 6 looks. Integration buys detection with time.

**Answer:** $P_D$ = 0.82 at $P_F$ = 10⁻³, and a target with d = 2 per look needs 6 looks for 1% error.
:::
:::

::: example
## An optical receiver sees on average 1 count per bit time with the laser off and 10 with it on. Using "decide on if 5 or more counts," find $P_F$ and $P_D$.

::: solution
1. **False alarms.** With the laser off the mean count is 1:
   $$\begin{aligned} P_F &= 1 - \sum_{k=0}^{4} \frac{e^{-1}1^k}{k!} \\ &= 1 - 0.99634 \\ &= 0.0037 \end{aligned}$$
2. **Detections.** With it on the mean is 10:
   $$\begin{aligned} P_D &= 1 - \sum_{k=0}^{4} \frac{e^{-10}10^k}{k!} \\ &= 1 - 0.0293 \\ &= 0.971 \end{aligned}$$
3. **Threshold at 4.** Lowering the threshold to 4 raises both: $P_F$ = 0.019 and $P_D$ = 0.990.
4. **Large steps.** The step from one integer threshold to the next is a large jump along the ROC, which is characteristic of counting receivers at low photon numbers.

**Answer:** $P_F$ = 0.0037 and $P_D$ = 0.971.
:::
:::

::: example
## A receiver sees mean 0 or 2 V in Gaussian noise of σ = 1 V, and the 2 V symbol is sent only 20% of the time. Where should the minimum-error threshold be, and how much does it beat the midpoint threshold?

::: solution
1. **Threshold.** With η = $P_0/P_1$ = 4:
   $$\begin{aligned} \gamma &= 1 + \frac12\ln 4 \\ &= 1.69\ \text{V} \end{aligned}$$
2. **False alarms and detections.**
   $$\begin{aligned} P_F &= Q(1.69) \\ &= 0.045 \end{aligned}$$
   $$\begin{aligned} P_D &= Q(1.69 - 2) \\ &= 0.621 \end{aligned}$$
3. **Error probability.**
   $$\begin{aligned} P_e &= 0.8 \times 0.045 \\ &\quad + 0.2 \times 0.379 \\ &= 0.112 \end{aligned}$$
4. **Midpoint threshold.** At 1 V it gives the same error whatever the priors:
   $$Q(1) = 0.159$$
5. **Why it helps.** Moving the threshold toward the rarer symbol trades a few more misses for many fewer false alarms.

**Answer:** the threshold belongs at 1.69 V, for an error probability of 0.112 against the midpoint's 0.159.
:::
:::

::: check
given: m = 1 | 2 | 4; s = 0.5 | 1; a = 0.6 | 0.7 | 0.9
answer: m/2 + s^2/m*ln((1 - a)/a)
unit: V
tolerance: 0.5%

## A receiver sees mean 0 or {m} V in Gaussian noise of σ = {s} V. The {m} V symbol is sent with probability {a}. Where's the minimum-error threshold, in volts?

::: right
Right. $m/2 + (\sigma^2/m)\ln(P_0/P_1)$ = {answer}.
:::

::: misses
- [m/2] That's for equal priors.
- [m/2 + s^2/m*ln(a/(1 - a))] The threshold moves toward the less likely symbol: use $\ln(P_0/P_1)$.
- [any] Not yet. Set the likelihood ratio equal to $P_0/P_1$ and solve for r.
:::
:::

::: check
given: g = 2.33 | 3.09 | 3.72; d = 2 | 3 | 4 | 5
answer: Q(g - d)
tolerance: 0.5%

## A Neyman–Pearson detector holds its threshold at {g}σ for the false-alarm rate it's allowed. With d = {d}, what's its detection probability?

::: right
Right. $Q(\gamma - d)$ = {answer}.
:::

::: misses
- [Q(g)] That's the false-alarm probability.
- [Q(d - g)] Measure the threshold from the signal's mean: $Q(\gamma - d)$.
- [any] Not yet. The H₁ density is centered at d.
:::
:::

::: check
given: d = 1 | 2 | 3 | 4
answer: Q(d/2)
tolerance: 0.5%

## With equal priors and d = {d}, what's the minimum error probability?

::: right
Right. $Q(d/2)$ = {answer}: the threshold sits halfway.
:::

::: misses
- [Q(d)] The threshold is at d/2, so each error tail starts d/2 from its mean.
- [any] Not yet. The ML threshold is halfway between the means.
:::
:::

::: check
given: m = 0.1 | 0.3 | 0.5; s = 1 | 2; N = 16 | 64 | 400
answer: m*sqrt(N)/s
tolerance: 0.5%

## A level of {m} V must be detected in noise of σ = {s} V using {N} independent samples. What's the detectability d of their sum?

::: right
Right. $m\sqrt N/\sigma$ = {answer}: the signal adds N times, the noise only √N times.
:::

::: misses
- [m*N/s] Noise adds too, in power: the sum's σ grows as √N.
- [m/s] Using N samples improves d by √N.
- [any] Not yet. Signal grows as N, noise as √N.
:::
:::

::: check
given: s = 0.5 | 1 | 3; N = 10 | 100 | 1000
answer: s/sqrt(N)
tolerance: 0.5%

## A constant is estimated from {N} independent samples with Gaussian noise of σ = {s}. What's the smallest possible standard deviation of an unbiased estimate?

::: right
Right. The Cramér–Rao bound, $\sigma/\sqrt N$ = {answer}, which the sample mean achieves.
:::

::: misses
- [s^2/N] That's the variance. Take its square root.
- [s/N] The standard deviation falls as $1/\sqrt N$.
- [any] Not yet. $I = N/\sigma^2$, and the bound is $1/I$ on the variance.
:::
:::

::: check
given: P = 0.5 | 0.8; C = 3 | 10 | 100; m = 1 | 2
answer: m/2 + 1/m*ln(P/((1 - P)*C))
tolerance: 0.5%

## A detector sees mean 0 (H₀, prior {P}) or {m} (H₁) in unit-variance Gaussian noise. Missing H₁ costs {C} times as much as a false alarm; correct decisions cost nothing. Where's the Bayes threshold?

::: right
Right. η = $P_0C_{10}/(P_1C_{01})$, so γ = {answer}.
:::

::: misses
- [m/2 + 1/m*ln(P/(1 - P))] Include the cost ratio in η.
- [m/2 + 1/m*ln(P*C/(1 - P))] Expensive misses lower the threshold: divide by the miss cost.
- [any] Not yet. $\gamma = m/2 + (\sigma^2/m)\ln\eta$.
:::
:::

::: check
kind: parts
given: m = 1 | 2 | 4; s = 0.5 | 1; p = 0.1 | 0.3

## A receiver sees mean 0 or {m} V in Gaussian noise of σ = {s} V; the {m} V symbol has prior {p}.

::: part
answer: m/2 + s^2/m*ln((1 - p)/p)
unit: V
tolerance: 0.5%

### Where is the minimum-error threshold?

::: misses
- [m/2] With unequal priors the threshold moves toward the rarer symbol.
- [any] $\frac m2 + \frac{\sigma^2}{m}\ln\frac{P_0}{P_1}$.
:::
:::

::: part
answer: (1 - p)*Q((m/2 + s^2/m*ln((1 - p)/p))/s) + p*(1 - Q((m/2 + s^2/m*ln((1 - p)/p))/s - m/s))
tolerance: 1%

### What error probability results?

::: misses
- [any] $P_0P_F + P_1(1 - P_D)$.
:::
:::
:::

::: check
kind: derivation
vars: m = 0.5..5, s = 0.1..2, e = 0.1..10

## A receiver tests mean 0 against mean m in Gaussian noise σ = s with likelihood-ratio threshold e.

::: step
answer: m/2 + s^2/m*ln(e)

### What threshold on r does that become?
:::

::: step
answer: Q((m/2 + s^2/m*ln(e))/s)

### What is the false-alarm probability?
:::

::: step
answer: Q((m/2 + s^2/m*ln(e))/s - m/s)

### What is the detection probability?
:::

::: right
Right. Sweeping e traces the whole ROC; each criterion just picks a point on it.
:::
:::

::: explain
## Why does every optimal detector compare a likelihood ratio with a threshold, whatever the criterion?

::: model
Any decision rule divides the space of possible observations into two regions, and its performance depends only on two numbers: the probability of falsely deciding H₁ and the probability of correctly deciding it. To get the most detection for a given amount of false alarm, each observation should be assigned to H₁ in order of how much detection probability it adds per unit of false-alarm probability it costs, which is exactly the ratio $p(r|H_1)/p(r|H_0)$. So the best region is always the set of observations whose likelihood ratio exceeds some threshold. The criteria differ only in how they price the two kinds of error: Bayes uses priors and costs, MAP uses priors alone, and Neyman–Pearson fixes the false-alarm rate. Each picks a different threshold on the same ratio, and so a different point on the same ROC.
:::
:::

::: practice

::: check
given: d = 0.5..6
answer: Q(d/2)
tolerance: 0.5%

## Minimum error probability, equal priors, d = {d}?

::: misses
- [any] $Q(d/2)$.
:::
:::

::: check
given: m = 0.5..4; s = 0.2..2; a = 0.1..0.9
answer: m/2 + s^2/m*ln((1 - a)/a)
tolerance: 0.5%

## MAP threshold: means 0 and {m}, σ = {s}, $P_1$ = {a}?

::: misses
- [any] $m/2 + (\sigma^2/m)\ln(P_0/P_1)$.
:::
:::

::: check
given: s = 0.1..5; N = 2..5000
answer: s/sqrt(N)
tolerance: 0.5%

## Cramér–Rao bound (as a standard deviation): σ = {s}, N = {N}?

::: misses
- [any] $\sigma/\sqrt N$.
:::
:::
:::
