Demo: Detection Theory

For a Gaussian mean-shift test, decide $H_1$ when the sample mean exceeds a threshold. The plot connects the likelihood-ratio idea with false-alarm and detection probabilities.

Mathematical setup

Consider

\[H_0:X_i\sim N(0,\sigma^2), \qquad H_1:X_i\sim N(\mu_1,\sigma^2), \qquad \mu_1>0.\]

For iid observations, the sample mean is sufficient for this one-sided mean-shift test:

\[\bar X\mid H_0\sim N\left(0,\frac{\sigma^2}{n}\right), \qquad \bar X\mid H_1\sim N\left(\mu_1,\frac{\sigma^2}{n}\right).\]

The threshold rule is decide $H_1$ when $\bar X>\gamma$, so

\[P_{\mathrm{FA}}=\Pr_0(\bar X>\gamma), \qquad P_D=\Pr_1(\bar X>\gamma).\]

Equivalently,

\[P_{\mathrm{FA}}=1-\Phi\left(\frac{\gamma\sqrt n}{\sigma}\right), \qquad P_D=1-\Phi\left(\frac{(\gamma-\mu_1)\sqrt n}{\sigma}\right).\]

Sweeping $\gamma$ traces out the ROC curve.

What to try

  • Move $\gamma$ right. False alarms decrease, but missed detections increase.
  • Increase $\mu_1$ or $n$. The two statistic distributions separate more, improving the ROC.
  • Increase $\sigma$. The distributions overlap more, so the same threshold becomes less decisive.

The operating probabilities are $P_{\mathrm{FA}}=P_0(\bar X>\gamma)$ and $P_D=P_1(\bar X>\gamma)$.

Try it in Python

This cell computes the false-alarm and detection probabilities for the displayed threshold and traces the ROC curve.

import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

n = 10
mu1 = 1.0
sigma = 1.0
gamma = 0.45

se = sigma / np.sqrt(n)
p_fa = stats.norm.sf(gamma, loc=0, scale=se)
p_d = stats.norm.sf(gamma, loc=mu1, scale=se)

gamma_grid = np.linspace(-1, 3, 300)
roc_fa = stats.norm.sf(gamma_grid, loc=0, scale=se)
roc_d = stats.norm.sf(gamma_grid, loc=mu1, scale=se)

plt.plot(roc_fa, roc_d, label="ROC")
plt.scatter([p_fa], [p_d], color="black", label="current threshold")
plt.plot([0, 1], [0, 1], color="gray", linestyle="--")
plt.xlabel("false-alarm probability")
plt.ylabel("detection probability")
plt.legend()
plt.show()

print(f"P_FA = {p_fa:.4f}")
print(f"P_D  = {p_d:.4f}")
print(f"miss probability = {1 - p_d:.4f}")

Back to topic notes