Parameter Estimation and Binary Hypothesis Testing

Maximum likelihood estimation for discrete observations (binomial, uniform, geometric, Poisson, capture–recapture); binary hypothesis testing with discrete observations: likelihood matrices, false alarms and misses, the ML rule and likelihood ratio tests, the MAP rule and its minimum-error optimality, with coin, photon-counting and sensor-fusion examples. Continuous-type estimation and testing are pending.

· 10 min read · 1,920 words

Two faces of the same likelihood machinery. Estimation picks the parameter value that makes the observed data most probable — once where the likelihood is a pmf (discrete-type observations) and once where it’s a pdf (continuous-type observations, e.g. a Gaussian’s mean/variance or an exponential’s rate). Testing asks a discrete question instead of a continuous one: given an observation generated under one of two competing hypotheses, decide which — via the ML rule (likelihood ratio vs. 1) or the MAP rule (likelihood ratio vs. a prior-odds threshold), again for both discrete- and continuous-type observations.

Maximum likelihood parameter estimation

DefinitionLikelihood and the ML estimate (Hajek §2.8)

Suppose XX has pmf pθp_\theta with an unknown parameter θ\theta, and we observe X=kX = k. The likelihood of θ\theta is pθ(k)p_\theta(k), viewed as a function of θ\theta with kk fixed. The maximum likelihood estimate is θ^ML(k)=arg⁡max⁡θpθ(k),\hat\theta_{ML}(k) = \arg\max_\theta p_\theta(k), the parameter value under which the observation is least surprising.

ComponentDetail
Fixedthe observation kk
Variedthe parameter θ\theta
Maximizedpθ(k)p_\theta(k), or equivalently ln⁡pθ(k)\ln p_\theta(k)
Nota probability distribution over θ\theta (no prior is involved)

WarningMaximize over θ\theta, not over kk

Maximizing pθ(k)p_\theta(k) over kk with θ\theta known answers a different question: the best guess of the next observation. Estimation fixes the data and varies the parameter.

ExampleFour ML estimates (Hajek)

ModelObservationLikelihoodθ^ML\hat\theta_{ML}
binomial(n,p)(n,p) (a bent coin)kk heads in nn flips(nk)pk(1−p)n−k\binom nkp^k(1-p)^{n-k}p^=k/n\hat p = k/n
uniform on {1,…,n}\{1,\dots,n\}X=kX = k1n1{n≥k}\frac1n\mathbf 1\{n\ge k\}n^=k\hat n = k
geometric(p)(p)L=kL = k(1−p)k−1p(1-p)^{k-1}pp^=1/k\hat p = 1/k
Poisson(λ)(\lambda)X=kX = kλke−λ/k!\lambda^ke^{-\lambda}/k!λ^=k\hat\lambda = k
DerivationWhere each maximum is

Binomial: ddppk(1−p)n−k=(k−np)pk−1(1−p)n−k−1\frac d{dp}p^k(1-p)^{n-k} = (k - np)p^{k-1}(1-p)^{n-k-1}, positive for p<k/np < k/n and negative after. The endpoint cases k=0k = 0 and k=nk = n give p^=0\hat p = 0 and 11, also equal to k/nk/n.

Uniform: the likelihood is 0 for n<kn < k, jumps to 1k\frac1k at n=kn = k, and decreases after, so n^=k\hat n = k.

Geometric: ddp(1−p)k−1p=(1−kp)(1−p)k−2\frac d{dp}(1-p)^{k-1}p = (1 - kp)(1-p)^{k-2}, which changes sign at p=1/kp = 1/k. For k=1k = 1 the likelihood pp peaks at p=1=1/kp = 1 = 1/k.

Poisson: ddλλke−λ=(k−λ)λk−1e−λ\frac d{d\lambda}\lambda^ke^{-\lambda} = (k - \lambda) \lambda^{k-1}e^{-\lambda}, which changes sign at λ=k\lambda = k. For k=0k = 0 the likelihood e−λe^{-\lambda} peaks at λ=0\lambda = 0.

ExampleCapture–recapture

The hypergeometric ML estimate of a population size, N^=⌊mn/i⌋\hat N = \lfloor mn/i\rfloor, is worked out in discrete-random-variables-and-distributions.


Binary hypothesis testing (discrete-type observations)

DefinitionThe testing problem (Hajek §2.11)

Exactly one of two hypotheses is true, H1H_1 or H0H_0. The observation XX has pmf p1p_1 under H1H_1 and p0p_0 under H0H_0. A decision rule declares H1H_1 or H0H_0 for each possible value of XX.

graph LR
  H["Switch: H1 or H0 is true"] --> S["System generates X with pmf p1 or p0"]
  S --> D["Decision rule"]
  D --> O["Declare H1 or H0"]

DefinitionLikelihood matrix, false alarm, miss

The likelihood matrix has one row per hypothesis and one column per value of XX, with entries pi(k)p_i(k). Mark one entry per column to specify a rule. Then:

  • pfalse alarm=P(declare H1∣H0)p_{\text{false alarm}} = P(\text{declare }H_1\mid H_0) is the sum of the unmarked H0H_0 entries (statistics: type I error);
  • pmiss=P(declare H0∣H1)p_{\text{miss}} = P(\text{declare }H_0\mid H_1) is the sum of the unmarked H1H_1 entries (type II error).

Both are conditional probabilities.

ExampleA running likelihood matrix (Hajek)

X=0X = 0X=1X = 1X=2X = 2X=3X = 3
H1H_10.00.10.30.6
H0H_00.40.30.20.1

Rule “declare H1H_1 iff X≥1X\ge1”: pfa=.3+.2+.1=.6p_{\text{fa}} = .3 + .2 + .1 = .6 and pmiss=0p_{\text{miss}} = 0. Switching the X=1X = 1 column to H0H_0 gives pfa=.3p_{\text{fa}} = .3 and pmiss=.1p_{\text{miss}} = .1.

ImportantEvery change trades one error for the other

Moving a column’s mark from one row to the other unmarks one entry and marks another, so one error probability rises as the other falls. In general no rule makes both small. Hajek’s advice: compute the pair (pfa,pmiss)(p_{\text{fa}}, p_{\text{miss}}) for several rules, then choose.

Maximum likelihood (ML) decision rule

DefinitionML rule and the likelihood ratio test

Declare the hypothesis under which the observation is more likely: mark the larger entry in each column. Equivalently, with the likelihood ratio

Λ(k)=p1(k)p0(k),declare H1 iff Λ(X)>1.\Lambda(k) = \frac{p_1(k)}{p_0(k)},\qquad\text{declare }H_1\text{ iff } \Lambda(X) > 1.

A likelihood ratio test (LRT) with threshold τ\tau declares H1H_1 iff Λ(X)>τ\Lambda(X) > \tau. Raising τ\tau lowers pfap_{\text{fa}} and raises pmissp_{\text{miss}}. The ML rule is the LRT with τ=1\tau = 1.

ExampleML rule for the running matrix

Declare H1H_1 for X∈{2,3}X\in\{2,3\} and H0H_0 for X∈{0,1}X\in\{0,1\}: pfa=.2+.1=.3p_{\text{fa}} = .2 + .1 = .3 and pmiss=.0+.1=.1p_{\text{miss}} = .0 + .1 = .1.

Maximum a posteriori (MAP) decision rule

DefinitionPriors and the joint probability matrix

Assume priors πi=P(Hi)\pi_i = P(H_i). The joint probability matrix has entries P(Hi,X=k)=πipi(k)P(H_i, X = k) = \pi_ip_i(k): each likelihood row scaled by its prior. All its entries sum to 1.

DefinitionMAP rule

Declare the hypothesis with the larger posterior P(Hi∣X=k)P(H_i\mid X = k). Both posteriors share the denominator P{X=k}P\{X = k\} (Bayes’ formula), so this means marking the larger entry in each column of the joint matrix. Equivalently,

declare H1  ⟺  π1p1(X)>π0p0(X)  ⟺  Λ(X)>π0π1.\text{declare }H_1\iff\pi_1p_1(X) > \pi_0p_0(X)\iff\Lambda(X) > \frac{\pi_0}{\pi_1}.

MAP is the LRT with τ=π0/π1\tau = \pi_0/\pi_1. With a uniform prior it reduces to ML.

TheoremMAP minimizes the average error probability

For any rule, pe=π0pfa+π1pmissp_e = \pi_0p_{\text{fa}} + \pi_1p_{\text{miss}} equals the sum of the unmarked entries of the joint matrix. MAP marks the larger entry in every column, so it leaves the smallest possible sum unmarked. Hajek calls it the minimum-probability-of-error rule.

IntuitionWhy a larger π0\pi_0 raises the threshold

If H0H_0 is a priori much likelier, it takes stronger evidence (a larger likelihood ratio) to declare H1H_1.

ExampleMAP for the running matrix, π0=.8\pi_0 = .8

X=0X = 0X=1X = 1X=2X = 2X=3X = 3
H1H_1.00.02.06.12
H0H_0.32.24.16.08

MAP declares H1H_1 only for X=3X = 3. That gives pfa=.1p_{\text{fa}} = .1, pmiss=.4p_{\text{miss}} = .4 and pe=.16p_e = .16, versus pe=.8(.3)+.2(.1)=.26p_e = .8(.3) + .2(.1) = .26 for the ML rule. (These three numbers are computed here, not in Hajek.)

ExampleFair or biased coin, 5 flips (Hajek)

H1H_1: heads with probability 23\frac23; H0H_0: fair. XX = heads in 5 flips. The binomial coefficients cancel in the ratio:

Λ(k)=(2/3)k(1/3)5−k(1/2)5=2k32243≈2k7.6.\Lambda(k) = \frac{(2/3)^k(1/3)^{5-k}}{(1/2)^5} = 2^k\frac{32}{243}\approx \frac{2^k}{7.6}.
RuleDeclares H1H_1 iffpfap_{\text{fa}}pmissp_{\text{miss}}pep_e with (π0,π1)=(.2,.8)(\pi_0,\pi_1) = (.2,.8)
ML (τ=1\tau = 1)X≥3X\ge3.551/243≈.21051/243\approx.210.268
MAP (τ=.25\tau = .25)X≥1X\ge11−2−5≈.971 - 2^{-5}\approx.971/243≈.00411/243\approx.0041.197

ExamplePhoton counting (Hajek)

A laser sends a bit. The photon count is Poisson(6) for a one and Poisson(2) for a zero:

Λ(k)=(62)ke−(6−2)=3ke−4≈3k54.6.\Lambda(k) = \Big(\frac62\Big)^ke^{-(6-2)} = 3^ke^{-4}\approx\frac{3^k} {54.6}.
  • ML: declare one iff 3X≥54.63^X\ge54.6, i.e. X≥4X\ge4.
  • MAP with zeros 5 times likelier (π0/π1=5\pi_0/\pi_1 = 5): declare one iff 3X≥2733^X\ge273, i.e. X≥6X\ge6.

On X=4X = 4 or 55 the rules disagree: the evidence favors a one, but the prior favors a zero more.

ExampleSensor fusion (Hajek)

Two motion sensors report X,Y∈{0,1,2}X, Y\in\{0,1,2\}, and H1H_1 = a person is present. The readings are conditionally independent given the hypothesis, so the joint likelihoods multiply:

XX=012YY=012
H1H_1.1.3.6.1.1.8
H0H_0.8.1.1.7.2.1
(X,Y)(X,Y)000102101112202122
H1H_1.01.01.08.03.03.24.06.06.48
H0H_0.56.16.08.07.02.01.07.02.01
  • ML (tie at (0,2) broken toward H1H_1): declare H1H_1 on {02,11,12,21,22}\{02, 11, 12, 21, 22\}. pfa=.14p_{\text{fa}} = .14 and pmiss=.11p_{\text{miss}} = .11.
  • MAP with π1=.2\pi_1 = .2: declare H1H_1 iff p1>4p0p_1 > 4p_0, only on {12,22}\{12, 22\}. pfa=.02p_{\text{fa}} = .02, pmiss=.28p_{\text{miss}} = .28, and pe=.8(.02)+.2(.28)=.072p_e = .8(.02) + .2(.28) = .072.
  • ML’s average error under the same priors: .8(.14)+.2(.11)=.134.8(.14) + .2(.11) = .134, larger, as MAP optimality guarantees.

Still to write

NoteTODO — ML parameter estimation for continuous-type variables

Needs Hajek’s continuous-observation version (maximizing a pdf). Source text not yet in sources/.

NoteTODO — Binary hypothesis testing with continuous-type observations

Needs Hajek’s continuous version (LRTs with pdfs). Source text not yet in sources/.


Quick reference

ObjectStatementNote
ML estimateθ^=arg⁡max⁡θpθ(k)\hat\theta = \arg\max_\theta p_\theta(k)data fixed, parameter varied
Standard ML estimatesbinomial k/nk/n; geometric 1/k1/k; Poisson kk; uniform kk
False alarm / missP(declare H1∣H0)P(\text{declare }H_1\mid H_0) / P(declare H0∣H1)P(\text{declare }H_0\mid H_1)type I / type II
Likelihood ratioΛ(k)=p1(k)/p0(k)\Lambda(k) = p_1(k)/p_0(k)LRT: declare H1H_1 iff Λ>τ\Lambda > \tau
ML ruleLRT with τ=1\tau = 1larger entry per column
MAP ruleLRT with τ=π0/π1\tau = \pi_0/\pi_1minimizes pe=π0pfa+π1pmissp_e = \pi_0p_{\text{fa}} + \pi_1p_{\text{miss}}

Facts to keep to hand

  • One likelihood, two uses. Estimation maximizes pθ(k)p_\theta(k) over a range of parameters. Testing compares it across two hypotheses.
  • Every rule here is a likelihood ratio test. ML and MAP differ only in the threshold, and the threshold is the prior odds. Moving it trades false alarms for misses.
  • MAP is optimal for the prior you assumed. It minimizes average error under that prior. Reporting both conditional error probabilities, as Hajek recommends, shows what the choice of rule costs.

References

← All notes