parametric: we know the shape, e.g. a Gaussian, but not its parametersθ
Today: from samples x1,…,xN and a model p(x∣θ), estimate θ. Three ways: maximum likelihood (ML), maximum a posteriori (MAP), Bayesian estimation.
A known shape with unknown numbers
A parametric modelp(x∣θ): a whole family of densities, one for each value of θ.
data x
model
unknown θ
coin flips: H or T
Bernoulli: P(H)=θ
θ
serial number of a captured tank
uniform on {1,…,θ}
θ = how many tanks
a die: faces 1,…,K
categorical: P(x=k)=pk
p1,…,pK
a measurement (letter A)
Normal N(μ,σ2)
μ,σ2
All four appear today; the last two are the assignment. Once we have θ^ for each class, p(x∣k,θ^k) goes into the Bayes classifier from lab 2.
Part II
Parameter estimation: ML, MAP, Bayesian
A coin: how likely is heads?
We flip a coin 8 times: H H T H H H H H (7 heads, 1 tail).
What is θ=P(heads) for this coin?
The obvious guess: 87=0.875. Where does it come from, and is it the best guess?
Would you bet that a coin from your pocket lands heads 87.5 % of the time?
Notation
θ = what we want to know but cannot see: here θ=P(heads). D={x1,…,xN} = what we observed.
We assume the flips are i.i.d.: independent, each from the same p(x∣θ).
How probable are our flips?
Our data: H H T H H H H H (7 heads, 1 tail). If heads has probability θ, how probable is this sequence?
↓ one flip
p(H∣θ)=θ,p(T∣θ)=1−θ
↓ the flips are independent: multiply, one factor per flip
θ⋅θ⋅(1−θ)⋅θ⋯θ=θ7(1−θ)
↓ the same for any i.i.d. data D=(x1,…,xN)
p(D∣θ)=i=1∏Np(xi∣θ)
As a function of θ (data fixed): the likelihoodL(θ).
Quick check: what is a likelihood?
The likelihood L(θ)=p(D∣θ), seen as a function of θ. Which is true?
p(D∣θ) is a distribution over the data D, one for each θ. Over θ its integral can be anything: for our flips ∫01θ7(1−θ)dθ=721. A distribution over θ needs a prior and Bayes' rule (MAP, Bayes).
Which θ explains the data best?
Data: H H T H H H H H (7 H, 1 T), L(θ)=θ7(1−θ). Where is it largest?
Maximum likelihood:θ^ML=argmaxθL(θ): the θ under which our data were most probable.
Right: the logarithm. It has its peak at the same θ; we will see why it is easier to work with.
Recap: derivatives
f(θ)
f′(θ)
c (no θ in it)
0
θn
nθn−1 (also θ1=θ−1)
logθ
θ1
eθ
eθ
af+bg
af′+bg′
f⋅g
f′g+fg′ (product rule)
f1f2⋯fN
∑ifi′∏j=ifj (one factor at a time)
gf
g2f′g−fg′ (quotient rule)
f(g(θ))
f′(g(θ))g′(θ) (chain rule)
↓ product rule on the coin likelihood itself, f=θ7, g=1−θ
dθdθ7(1−θ)=7θ6(1−θ)−θ7=θ6(7−8θ)
Zero at θ=87. A product of N factors gives N terms of N factors each. With the log it is a sum of simple terms:
(logi∏fi)′=i∑(logfi)′=i∑fifi′
↓ chain rule: outer logu, inner u=1−θ, u′=−1
dθdlog(1−θ)=1−θ1⋅(−1)=−1−θ1
Several parameters (μ,σ2): partial derivatives, one at a time, the others held fixed. Treat σ2 as one variable v: dvdv1=−v21.
Where can a maximum be?
Candidates: points where f′=0, the edges of the allowed range, and points where f′ does not exist.
Then compare f at the candidates, or check f′′<0 at a point with f′=0.
How do we find the maximum?
General coin: NH heads, NT tails, N=NH+NT. Where can the maximum be?
↓ edges: L(0)=0 if NH≥1, L(1)=0 if NT≥1; inside L>0. So the maximum is inside (0,1), where the slope is 0. (H H H: NT=0, maximum at the edge θ=1.)
↓ take the log: products become sums, and log is increasing, so the argmax does not move
ℓ(θ)=logL(θ)=NHlogθ+NTlog(1−θ)
↓ derivative: (logθ)′=θ1, (log(1−θ))′=−1−θ1; set it to 0
dθdℓ=θNH−1−θNT=0
↓ multiply by θ(1−θ)
NH(1−θ)=NTθ⇒NH=(NH+NT)θ
↓ divide by N
θ^ML=NNH
Our coin: 7 H, 1 T
θ^ML=87=0.875
The "obvious" relative frequency is the ML estimate. The log trick is used in every derivation today (and in the assignment).
Bonus: in code, a product of 1000 small numbers underflows to 0, a sum of logs does not.
Quick check
You flip a new coin 3 times: H H H. The ML estimate of θ is…
θ^ML=NNH=33=1: the model now says tails is impossible.
What would make the estimate after H H H more sensible?
The log does not move the maximum. What is missing is prior knowledge: most coins are close to fair. That is what MAP adds.
How can we use what we knew before?
Treat θ as a random variable with a priorp(θ): our belief before seeing D. Then ask for the most probable θafter seeing D.
↓ Bayes' rule, as in lab 2 with H=θ, E=D
p(θ∣D)=p(D)p(D∣θ)p(θ)
↓ p(D) does not depend on θ: it does not move the argmax
θ^MAP=argθmaxp(θ∣D)=argθmaxp(D∣θ)p(θ)
↓ take the log
=argθmax[logp(D∣θ)+logp(θ)]
Names
priorp(θ): before the data
likelihoodp(D∣θ): what the data say
posteriorp(θ∣D): after the data
ML = MAP with a flat prior: if p(θ) is constant, it does not move the argmax either.
The coin with a prior
Same data (7 H, 1 T). Prior: p(θ)∝θa−1(1−θ)b−1 (a Beta(a,b) density); here a=b=5: "most coins are roughly fair".
↓ likelihood times prior: the exponents add up
p(θ∣D)∝θNH+a−1(1−θ)NT+b−1
↓ same shape as the likelihood, with NH+a−1 heads and NT+b−1 tails: same derivation as before
θ^MAP=N+a+b−2NH+a−1
=8+87+4=1611=0.688 (ML: 0.875)
The prior acts like a−1=4 extra heads and b−1=4 extra tails.
Why choose a single θ at all?
The posterior says many values of θ are plausible. To predict the next flip, average the prediction of every θ, weighted by how plausible it is.
↓ the expectation you know: E[f(z)]=∫p(z)f(z)dz, with z=θ and f(θ)=p(x∣θ)
p(x∣D)=∫p(x∣θ)p(θ∣D)dθ
↓ coin: p(H∣θ)=θ, so we need the mean of the posterior
p(H∣D)=∫θp(θ∣D)dθ=E[θ∣D]
↓ the posterior is Beta(NH+a,NT+b); the mean of Beta(α,β) is α+βα (derived on the next slide)
p(H∣D)=N+a+bNH+a
Our coin: 7 H, 1 T
8+107+5=1812=0.667
The result is a predictive distributionp(x∣D), not a parameter value. For the coin it is again "heads with prob. 0.667"; for a Gaussian it is not a Gaussian any more (assignment).
Where does the posterior mean come from?
Posterior Beta(α,β), for our coin α=NH+a=12, β=NT+b=6:
↓ the integral is the same normaliser, with α+1 instead of α
=B(α,β)B(α+1,β)
↓ for whole numbers B(α,β)=(α+β−1)!(α−1)!(β−1)!; most factorials cancel
=(α+β)!α!(β−1)!⋅(α−1)!(β−1)!(α+β−1)!=α+βα
Our coin: 7 H, 1 T, prior Beta(5, 5)
E[θ∣D]=12+612=1812=0.667
Sanity check: flat Beta(1,1), no data: 21. The trick "the integral is a normaliser you already know" comes back with the Dirichlet and the NIG in the assignment.
Three estimators side by side
what it computes
prior?
result
coin
ML
argmaxθp(D∣θ)
no
one θ^, plug in p(x∣θ^)
0.875
MAP
argmaxθp(D∣θ)p(θ)
yes
one θ^, plug in p(x∣θ^)
0.688
Bayes
∫p(x∣θ)p(θ∣D)dθ
yes
a distribution p(x∣D)
0.667
Lots of data: the likelihood dominates the prior, all three agree.
Little data: ML can be extreme (θ^=1 after H H H), the prior keeps MAP and Bayes sensible, if the prior is sensible.
Try it: prior, likelihood, posterior
Two ways to think about θ
xkcd.com/1132 (Randall Munroe, CC BY-NC 2.5)
Frequentist:θ is a fixed unknown number; only the data are random. Report the θ that makes the data most likely: ML.
Bayesian:θ is uncertain, so give it a distribution. The prior p(sun exploded) is tiny, and one "YES" from a detector that lies 1/36 of the time does not beat it.
What each one thinks about, in order of "evolution":
θa priori
→
xpragmatic
→
x∣θfrequentist
→
x,θjoint
→
θ∣xBayesian
Part III
German tank problem
German tank problem
Given: tanks are marked with consecutive whole numbers 1,2,…,θ.
Goal: estimate German tank production θ from a few captured tanks.
Captured: tanks no. 19, 40, 42, 60. How many tanks were produced?
Model: every produced tank is equally likely to be captured:
p(x∣θ)={θ10x∈{1,…,θ}otherwise
Panther production line (Bundesarchiv, CC BY-SA 3.0 DE)
The likelihood of θ
Sketch L(θ) first: what happens for θ<60? For θ≥60?
↓ if θ<60, tank 60 could not exist: one factor is 0
↓ otherwise every factor is θ1; k=4 tanks, m=maxixi=60
L(θ)=i=1∏kp(xi∣θ)={θ−k0θ≥mθ<m
↓ θ−k decreases: take the smallest allowed θ (the edge case from the recap: no slope 0 anywhere)
θ^ML=maxixi=60
Is 60 a good guess?
The largest captured number can never exceed θ: θ^ML≤θ always, so on average it is too small (biased).
↓ the k numbers split 1..m into gaps of average size km−1; assume one more gap above m
θ^=m+km−1
=60+460−1=74
This estimator is unbiased (on average exactly θ) and has the smallest variance among unbiased ones.
month
statistical
intelligence
German records
June 1940
169
1000
122
June 1941
244
1550
271
August 1942
327
1550
342
Monthly tank production estimates (Wikipedia, "German tank problem").
How was this really used?
1940s: serial numbers as intelligence
Allied economists collected serial numbers from captured and destroyed German tanks. Gearboxes came in two unbroken sequences; chassis and engine numbers and other parts were used to cross-check.
Road wheels of two Panthers
64 road wheels carried mould numbers → how many moulds were in use. British wheel makers said how many wheels a mould makes per month → ≈ 270 Panthers in February 1944. German records: 276.
Before D-Day, and after the war
Rumours of huge numbers of Panthers were checked against the serial-number estimates. After the war, the records of Speer's armaments ministry showed for June 1940 – Sept. 1942: intelligence ≈ 1400 tanks/month, serial numbers 246, true 245.
Afterwards
Published by Ruggles & Brodie (1947), the estimator "sample maximum + average gap" only in a footnote. The same trick estimated V-2 rocket production, Soviet equipment in the Korean War, Israeli Merkava tanks, and ≈ 12.5 million Commodore 64 computers.
R. Ruggles, H. Brodie, An Empirical Approach to Economic Intelligence in World War II, JASA 42 (1947); Wikipedia, "German tank problem".
What does Bayes say about θ?
Prior: no idea, except "at most 1000 tanks": p(θ)=10001 for θ=1,…,1000.
↓ Bayes' rule; a flat prior is a constant, so the posterior has the shape of the likelihood
p(θ∣D)=Zθ−k(m≤θ≤1000)
Z=∑t=m1000t−k makes it sum to 1.
↓ summarise the posterior by its middle (median) and its mean
median 75, mean 89 (ML: 60)
And an honest range: P(θ≤161∣D)=0.95. ML gives one number; Bayes also says how sure we are.
Which serial number will the next tank have?
Plug in θ^ML=60: "the next tank has a number from 1 to 60".
Is that believable after seeing only 4 tanks?
↓ Bayes: average the uniform p(x∣θ) over the posterior, as for the coin
p(x∣D)=θ∑p(x∣θ)p(θ∣D)
P(x>60∣D)=0.24 (ML plug-in: 0)
The ML plug-in is overconfident: it rules out every tank it has not seen. Same story as face 4 of the die and σML2 for 5 samples.
Try it: capture some tanks
Part IV
Exercises
Exercise: socks
You have red and blue socks. The proportion of red socks is π. You draw socks with replacement.
What does it mean to draw with replacement?
What is the probability of drawing two red socks in a row?
In N=10 draws you got R=2 red socks. What is the probability of drawing R red socks in N draws?
Compute the ML estimate of π.
RPZ exercise book: "Binomial Socks".
A loaded die: what are p1,…,p6?
We roll a die N=50 times. Counts Nk of each face:
face k
1
2
3
4
5
6
Nk
5
12
23
0
2
8
Model: categorical, P(x=k)=pk, with pk≥0 and ∑kpk=1.
↓ i.i.d. product; group equal faces: face k contributes pk exactly Nk times
L(p1,…,p6)=i=1∏Npxi=k=1∏6pkNk
Why not just set every derivative to 0? Each pkNk grows with pk: without the constraint ∑kpk=1, the "maximum" is pk→∞.
Maximize with the constraint ∑kpk=1
↓ log-likelihood, plus a Lagrange multiplier λ times the constraint
L(p,λ)=k∑Nklogpk+λ(1−k∑pk)
↓ derivative with respect to one pk: only one term of each sum depends on it
∂pk∂L=pkNk−λ=0⇒pk=λNk
↓ derivative with respect to λ gives back the constraint; plug in pk
k∑λNk=1⇒λ=k∑Nk=N
↓ put λ=N back
p^k=NNk
Our die
p^=(0.10,0.24,0.46,0,0.04,0.16)
Again the relative frequencies. Face 4 gets probability 0: never seen, so "impossible".
A prior for probabilities: Dirichlet
↓ same shape as the likelihood, with αk−1 instead of Nk ("pseudo-counts")
Dir(p;α)∝k∏pkαk−1
↓ MAP: maximize likelihood × prior, same steps as ML (you derive it in the assignment)
p^kMAP=∑m(Nm+αm−1)Nk+αk−1
αk=2: face 4: 50+60+1=0.018
↓ Bayes: the posterior is Dir(Nk+αk); average over it
p(x=k∣D)=∑m(Nm+αm)Nk+αk
αk=2: face 4: 50+120+2=0.032
Try it: pseudo-counts α
Quick check
Dirichlet prior with αk=1 for all k. The MAP estimate of p4 for our die (N4=0) is…
p^k=∑m(Nm+αm−1)Nk+αk−1=500+0=0: a flat prior adds nothing to the maximum.
Same prior, Bayesian predictive: p(x=4∣D) is…
p(x=k∣D)=∑m(Nm+αm)Nk+αk=50+60+1=561. Averaging over all plausible p never gives an unseen face exactly 0.
Part V
The assignment
The assignment in three parts
1 · Normal
Data from N(0,1). Estimate μ,σ2 by ML, MAP (normal-inverse-gamma prior) and Bayes.
plots for 1, 5, 50 samples; an outlier
2 · Categorical
The die from today. ML, MAP and Bayes with a Dirichlet prior.
samples from the prior and the posterior
3 · Classifier
Letters A vs. C (measurement from lab 2): Bayes classifier with each of the three estimates.
20, 200, 2000 training samples
Two handwritten derivations to submit as photos: MAP for the Normal (μ∗,σ2∗) and MAP for the categorical. The ML ones are practice for the tests (not graded).
Exercise: ML for a Normal distribution
Samples x1,…,xN i.i.d. from N(μ,σ2):
p(x∣μ,σ2)=2πσ21exp(−2σ2(x−μ)2)
Task: derive μ^ML and σ^ML2. Then compute them for x=(1,4,6,3,4,7).
Recipe from the coin: log-likelihood, derivative with respect to each parameter, set to 0.
How much should we trust σ^ML2?
Few samples: the fit is too narrow (too confident), and it changes a lot from sample to sample.
One sample: σ^ML2=0, an infinitely thin spike. A prior prevents that.
Is an estimator right on average?
An estimator is a recipe: data in, number out. New data set, new number. Imagine repeating the experiment many times.
↓ average the estimate over all possible data sets D of size N
bias(θ^)=ED[θ^(D)]−θ
Bias 0: unbiased, right on average.
E[σ^ML2]=NN−1σ2: 0.8 for N=5
μ^ sits in the middle of the samples, closer to them than the true μ, so the spread around it is too small. Divide by N−1: unbiased.
Which of our estimators are biased?
estimator
biased?
why / the fix
mean μ^=N1∑ixi
no
each xi is right on average
σ^ML2 (divide by N)
yes, low
divide by N−1
tank: θ^ML=maxixi
yes, low
never above θ; fix: m+km−1
MAP μ∗=N+ννμ0+∑ixi
yes, to μ0
on purpose: pulled towards the prior
relative frequency NNk
no
but 0 for unseen faces in many single data sets
All biases above vanish as N→∞: the estimators are consistent. Bias matters for smallN.
Is unbiased always better?
What we care about: how far the estimate is from the truth, on average.
↓ expand the square around the average estimate E[θ^]; the cross term averages to 0
E[(θ^−θ)2]=bias2+variance
σ2 from N=5 Gaussian samples, S=∑i(xi−μ^)2:
estimate
bias
variance
mean sq. error
S/(N−1)
0
0.50
0.50
S/N (ML)
−0.20
0.32
0.36
S/(N+1)
−0.33
0.22
0.33
Bias–variance trade-off
The unbiased estimate is the worst of the three here: a little bias buys a lot less variance.
Same idea as MAP and as the Bayesian average for films: pull towards a sensible value, accept some bias, get a much steadier estimate.
Try it: repeat the experiment
MAP for a Normal: a prior on (μ,σ2)
Conjugate prior: normal-inverse-gammaNIG(μ,σ2∣μ0,ν,α,β) (formula in the notebook). Read its parameters as imaginary data:
μ was estimated from ν samples with mean μ0
σ2 from 2α samples with sum of squared deviations 2β
First 5 samples of N(0,1); prior μ0=1, ν=2, α=2, peak at (μ,σ2)=(1,1). The same three maps as in your notebook.
Peak of the likelihood = ML ✕: σ2 too small for 5 samples.
The prior: our guess ○, a wide blob around it.
Product: its peak is MAP ◆, between ✕ and ○. Not normalised (we dropped p(D)).
Try it: the (μ,σ2) maps
Bayes for a Normal: average over (μ,σ2)
Conjugacy: the posterior is again NIG, only the parameters change (formulas in the notebook):
ν~=ν+N,α~=α+2N,μ~0=ν+Nνμ0+∑ixi,β~=…
ν and 2α just add the N real samples to the imaginary ones.
↓ predictive: integrate both parameters out
p(x∗∣D)=∬N(x∗∣μ,σ2)NIG(μ,σ2∣μ~0,ν~,α~,β~)dμdσ2
The notebook gives the closed form (κ). It is not a Normal: heavier tails, wider for small N.
What you implement
bayes_posterior_params_normal: the four new parameters
bayes_estim_pdf_normal: p(x∗∣D) on a grid of x∗
The posterior plot looks exactly like the MAP-objective plot: they differ only by the constant p(D), and matplotlib rescales the colours.
Try it: ML, MAP and Bayes for a Normal
What should you see in your plots?
Many samples: ML, MAP and Bayes agree and approach the true parameters. ML is the simplest.
Few samples: ML jumps around and σ^ML2 is too small (too confident).
MAP pulls towards the prior; replaces degenerate answers (σ2=0 for one sample) by sensible defaults.
Bayes is the most careful: heavier tails, some probability even for values not seen yet.
Outliers move ML and MAP: the model (one Gaussian) is wrong, not the method.
Priors must be chosen; a bad prior hurts (part 3).
Part 3: a Bayes classifier for A and C
Measurement x = compute_measurement_lr_cont (lab 2), 0/1 loss, priors p(A),p(C) = relative frequencies in the training set.
ML, MAP: two Gaussians, as in the Bayes lab: thresholds t1,t2 from the quadratic.
Bayes: the predictive is not Gaussian, so decide point by point:
p(A)p(x∣A,DA)>p(C)p(x∣C,DC)⇒A
Watch out
x is in the thousands: the prior (μ0=0,σ2=1) from part 1 is useless (next slide).
One prior per class.
With 20 training samples: ML gives 7.5 % test error; MAP and Bayes should beat it.
How do we choose a prior for A and C?
Approximate class shapes, read off the notebook's test-set plot.
Plot a histogram of each class's training samples.
μmy = where the class sits. σmy2 = (typical spread)²: it is a variance, so a spread of 500 means 2.5⋅105.
Keep it weak: small ν and α (1 to 3). The prior is then worth a few samples and the 20 real ones can still move it.
μ0=μmy, β=σmy2(α+1.5). Plot it with plot_prior on the data's range, one prior per class.
Quick check
Class C sits around −2000; most samples are within a few hundred of that. A sensible σmy2 is about…
A spread (standard deviation) of a few hundred, e.g. σ≈300, gives σ2≈9⋅104. 400 would be a standard deviation of 20.
You switch from 20 to 2000 training samples, same prior. The MAP estimates…
μ∗=N+ννμ0+∑ixi: with N=2000 and ν=2 the prior is 2 imaginary samples against 2000 real ones. (Only the Bayes predictive may overflow numerically: use logs.)
A film with 3 votes, all 10/10: best film ever? For years IMDb published how its Top 250 avoids that:
WR=v+mvR+v+mmC
R = the film's mean rating from v votes, C = mean over all films, m = a fixed number of votes.
Seen it before?
The MAP mean of the Normal: μ∗=N+νNxˉ+N+ννμ0
Every film starts with m imaginary votes at the global mean C: a prior worth m samples. Few votes → close to C; many votes → its own mean.
C=6.9. Slider is on a log scale.
Counting things you have never seen
Spam filter (naive Bayes)
p(word∣spam) estimated by counting words in known spam. A word never seen in spam gets ML estimate 0, so the product over the email's words is 0: one word decides everything.
Autocomplete, n-gram models
p(next word∣previous words) from counts in a corpus. Most word pairs never occur in the corpus, but they are not impossible.
Fix in both: add-one (Laplace) smoothingN+KNk+1 = the Bayes estimate with a Dirichlet prior, αk=1. That is face 4 of our die.
Your loss function is a likelihood
Training a network = minimizing a loss over the data. Which loss?
↓ ML for a model of the output y given the input x, written as a minimisation
θ^ML=argθmini∑−logp(yi∣xi,θ)
↓ classification: p(yi∣xi,θ) = predicted probability of the true class
−logp(yi∣xi,θ) is the cross-entropy loss.
↓ regression with Gaussian noise: y=fθ(x)+ε, ε∼N(0,σ2)
−logp(y∣x,θ)=2σ2(y−fθ(x))2+const
The squared error (MSE) loss.
So
Image classifiers, detectors and the next-word prediction that trains large language models are all trained by maximum likelihood.
Least squares (camera calibration, 3D reconstruction, line fitting) = ML with Gaussian errors: Gauss's own argument, 1809.
Bridge to next week: what is regularisation?
↓ MAP in logs, written as a minimisation
θ^MAP=argθmin[loss on the data−logp(D∣θ)penalty−logp(θ)]
↓ Gaussian prior on the weights: p(θ)∝exp(−2s2∥θ∥2)
−logp(θ)=2s21∥θ∥2+const
L2 regularisation (weight decay) = MAP with a Gaussian prior: "weights are probably small". A narrow prior = a strong penalty.
Next week: logistic regression is trained by ML (cross-entropy). Add λ∥w∥2 and it becomes MAP.
The epic story of maximum likelihood (TL;DR)
1700sBernoulli, Lagrange, Laplace: "the most probable value"
1809Gauss: normal errors → least squares
1912–1922Fisher: names it, claims it is the best
1948–1953counterexamples; Wald's proof; Le Cam
An "obvious" idea, used intuitively long before anyone could say when it works.
Fisher's claims (consistent, most efficient) took decades and several failed proofs; they hold under regularity conditions, not always.
It can fail: many parameters with few samples each (Neyman–Scott), or a maximum at the edge like the tank, where the usual theory does not apply.
Measurements X={1.5,−1,1.5,3,2,−0.5}. Kernel K(x,y)=k(x−y) with
k(z)={h10∣z∣≤2h∣z∣>2h,h=3
Task: plot the Parzen estimate p^(x). What is p^(2.5)?
RPZ exercise book: "Parzen Window Density Estimation".
Test 1: how did it go?
24 students, 12 points: mean 9.5, median 10.1, three full scores.
Q1 (Bayes) went well. Points were lost mostly in Q2 (Neyman–Pearson in 1A, minimax in 1B): the definition and the final error.
Pure slips (arithmetic, copying) cost only 0.25. The deductions on the next slide are about understanding.
part
average
max
Q1 a) definition
0.92
1
Q1 b), c) computation
3.58
4
Q1 d) Bayesian risk
0.79
1
Q2 a) definition
0.73
1
Q2 b) strategy
2.88
4
Q2 c) error
0.56
1
Test 1: common mistakes
Risk of a strategy vs. partial risk
Most wrote only the partial risk R(x,d)=∑kp(x,k)W(k,d) and a pointwise argmin. The task asks for the risk of a strategy: R(q)=∑x∑kp(x,k)W(k,q(x)), q∗=argminqR(q).
Conditional vs. joint
p(x∣k) instead of p(x,k) drops the priors. And p(k∣x)=p(x)p(x,k): divide by p(x), never multiply. Bayesian risk: weight the partial risks by p(x) again.
Integrate over the other region
6 of 23 integrated each density over its own decision region and got 1−ε. The error of class 1 is the mass of p(x∣1) where we decide 2: ε(1)=∫X2p(x∣1)dx.
Likelihood ratio + sanity checks
Write ℓ(x)=p(x∣2)p(x∣1) first: it gives the shape of the region (two tails in Neyman–Pearson: the constraint is on their sum). An error above 0.5 for two classes? Probably 1−ε.
Quick check
A table gives p(x,k). The column k=1 sums to 0.3. The entries of that column are…
p(x,k)=p(x∣k)p(k) and p(k=1)=∑xp(x,1)=0.3. Divide the column by 0.3 to get p(x∣k=1).
The strategy decides d=2 on X2 and d=1 elsewhere. The probability of a mistake on an object of class 1 is…
A class-1 object is misclassified when its x falls where we decide 2. c) is 1−ε(1), the most common mistake in test 1; b) is the probability that a class-2 object is classified correctly.
Optional
Extra material
The Bayes predictive of a Normal is a Student t
p(x∗∣D)=t2α~(x∗μ~0,α~ν~β~(ν~+1))
Degrees of freedom 2α~=2α+N: few samples → heavy tails, the uncertainty about σ2 shows.
N→∞: t→ Normal, the predictive becomes the MAP / ML Gaussian.
Same numbers as the κ formula in the notebook: a check for your implementation (the widget uses this form).