Skip to content

Maximum Likelihood Estimation

§8.2 never wrote down a probability. This section does, and the book is explicit about the mapping:

In Section 8.3.1, we introduce the likelihood, which is analogous to the concept of loss functions (Section 8.2.2) in empirical risk minimization. The concept of priors (Section 8.3.2) is analogous to the concept of regularization (Section 8.2.3).

This page does the first correspondence and page 805 does the second. And “analogous” turns out to be an understatement — measured, the two objectives are affine transforms of each other, so they rank every parameter identically.

  • Equation 8.14, the negative log-likelihood, and why the negative sign is there at all.
  • The interpretive point the book makes twice: p(xθ)p(\mathbf{x} \mid \boldsymbol\theta) read two ways is two different objects.
  • Measured: the likelihood does not integrate to 1 over θ\boldsymbol\theta — it integrates to 0.1044960.104496 in the worked case. It is not a distribution over parameters.
  • Equations 8.15–8.17: the supervised setting, and where the independence assumption turns a product into a sum.
  • Example 8.5, Equation 8.18: Gaussian maximum likelihood is least squares. Measured, the minimisers agree to 1.8×10151.8\times10^{-15} and the objectives differ by L=102.040816Remp3.272090\mathcal{L} = 102.040816\,R_{\text{emp}} - 3.272090.
  • The three asymptotic properties of the MLE, and the warning attached to them: measured, N×N \times error is roughly constant, confirming 1/N1/N decay.

Intuition: which knob best explains what you saw?

Section titled “Intuition: which knob best explains what you saw?”

You have a machine with a dial on it. Turn the dial to θ\boldsymbol\theta and the machine spits out numbers according to p(xθ)p(\mathbf{x} \mid \boldsymbol\theta). You did not see the dial, but you saw the numbers.

Maximum likelihood asks: which dial setting makes the numbers I saw least surprising? Not “which is most probable” — the dial has no probability attached, that would need a prior — but which setting assigns the highest density to the observations.

The whole trick is that p(xθ)p(\mathbf{x} \mid \boldsymbol\theta) can be read in two directions. Read it with θ\boldsymbol\theta nailed down and x\mathbf{x} free, it is a distribution over data. Read it with x\mathbf{x} nailed down — because you observed it — and θ\boldsymbol\theta free, it is the likelihood. Same formula. Different function, different variable, different meaning.

diagram Section 8.3.1, and where it lands mermaid

Equation 8.14: the negative log-likelihood

Section titled “Equation 8.14: the negative log-likelihood”

For data represented by a random variable x\mathbf{x} and a family of densities p(xθ)p(\mathbf{x} \mid \boldsymbol\theta):

Lx(θ)=logp(xθ)\mathcal{L}_{\mathbf{x}}(\boldsymbol\theta) = -\log p(\mathbf{x} \mid \boldsymbol\theta)

The subscript emphasises that θ\boldsymbol\theta is varying and x\mathbf{x} is fixed, and the book notes it is usually dropped, leaving L(θ)\mathcal{L}(\boldsymbol\theta) — “as it is really a function of θ\boldsymbol\theta”.

Three transformations happened in that one line, and each has a reason:

  • The logarithm. Independence makes the joint density a product over examples, and a product of NN small numbers underflows. §0.3 measured the failure: a product of 162162 probabilities of 0.010.01 reaches exactly 0.0 in float64. The logarithm turns it into a sum, which does not.
  • The negative sign. The book calls it “a historical artifact that is due to the convention that we want to maximize likelihood, but numerical optimization literature tends to study minimization of functions.” That is all it is.
  • Nothing else. log\log is strictly increasing and negation reverses order exactly once, so argmaxθp=argminθL\arg\max_{\boldsymbol\theta} p = \arg\min_{\boldsymbol\theta} \mathcal{L} with no approximation.

The book states this carefully, so it is worth quoting both halves.

Fix θ\boldsymbol\theta, vary x\mathbf{x}: “It is a distribution that models the uncertainty of the data. In other words, once we have chosen the type of function we want as a predictor, the likelihood provides the probability of observing data x\mathbf{x}.”

Fix x\mathbf{x}, vary θ\boldsymbol\theta: “It tells us how likely a particular setting of θ\boldsymbol\theta is for the observations x\mathbf{x}. Based on this second view, the maximum likelihood estimator gives us the most likely parameter θ\boldsymbol\theta for the set of data.”

Equations 8.15–8.17: the supervised setting

Section titled “Equations 8.15–8.17: the supervised setting”

Given pairs (x1,y1),,(xN,yN)(\mathbf{x}_1, y_1), \dots, (\mathbf{x}_N, y_N) with xnRD\mathbf{x}_n \in \mathbb{R}^D and ynRy_n \in \mathbb{R}, we specify the conditional distribution of the labels given the examples:

p(ynxn,θ)=N(ynxnθ, σ2)p(y_n \mid \mathbf{x}_n, \boldsymbol\theta) = \mathcal{N}\big(y_n \mid \mathbf{x}_n^\top\boldsymbol\theta,\ \sigma^2\big)

Read the model this asserts: the label is the linear prediction plus Gaussian noise of known variance. Note what §8.2 did not have to say — page 803’s §8.2.5 quote, that empirical risk minimization never has to “specify the noise distribution for the labels”. Here you do.

Then, using independence:

L(θ)=n=1Nlogp(ynxn,θ)\mathcal{L}(\boldsymbol\theta) = -\sum_{n=1}^{N}\log p(y_n \mid \mathbf{x}_n, \boldsymbol\theta)

Example 8.5: the derivation that collapses two frameworks into one

Section titled “Example 8.5: the derivation that collapses two frameworks into one”

Substituting the Gaussian and expanding, step by step:

L(θ)=n=1NlogN(ynxnθ, σ2)\mathcal{L}(\boldsymbol\theta) = -\sum_{n=1}^{N}\log \mathcal{N}\big(y_n \mid \mathbf{x}_n^\top\boldsymbol\theta,\ \sigma^2\big) =n=1Nlog[12πσ2exp((ynxnθ)22σ2)]= -\sum_{n=1}^{N}\log\left[\frac{1}{\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(y_n - \mathbf{x}_n^\top\boldsymbol\theta)^2}{2\sigma^2}\right)\right]

The logarithm splits the product inside into a sum:

=n=1Nlogexp((ynxnθ)22σ2)n=1Nlog12πσ2= -\sum_{n=1}^{N}\log\exp\left(-\frac{(y_n - \mathbf{x}_n^\top\boldsymbol\theta)^2}{2\sigma^2}\right) - \sum_{n=1}^{N}\log\frac{1}{\sqrt{2\pi\sigma^2}}

and logexp\log\exp cancels:

=12σ2n=1N(ynxnθ)2n=1Nlog12πσ2= \frac{1}{2\sigma^2}\sum_{n=1}^{N}\big(y_n - \mathbf{x}_n^\top\boldsymbol\theta\big)^2 - \sum_{n=1}^{N}\log\frac{1}{\sqrt{2\pi\sigma^2}}

The book’s conclusion: “As σ\sigma is given, the second term in (8.18d) is constant, and minimizing L(θ)\mathcal{L}(\boldsymbol\theta) corresponds to solving the least-squares problem.”

Compare the first term with Equation 8.8’s Remp=1Nn(ynθxn)2R_{\text{emp}} = \frac{1}{N}\sum_n (y_n - \boldsymbol\theta^\top\mathbf{x}_n)^2. They differ by the factor N2σ2\frac{N}{2\sigma^2}. So

L(θ)=N2σ2Remp(θ)+c,c=Nlog12πσ2\mathcal{L}(\boldsymbol\theta) = \frac{N}{2\sigma^2}\,R_{\text{emp}}(\boldsymbol\theta) + c, \qquad c = -N\log\frac{1}{\sqrt{2\pi\sigma^2}}

A positive multiple plus a constant. Neither operation can move an argmin\arg\min. Measured with N=25N = 25 and σ=0.35\sigma = 0.35: the slope is 102.040816102.040816, the constant is 3.272090-3.272090, and the two minimisers agree to 1.8×10151.8\times10^{-15}.

So §8.2 and §8.3 are not two methods that happen to agree on this example. For a Gaussian likelihood with known variance they are the same objective in different notation, and the choice between them is a choice of vocabulary — until §8.3.2 adds a prior, where the vocabularies start to buy different things.

§8.3.2’s remark: what maximum likelihood guarantees

Section titled “§8.3.2’s remark: what maximum likelihood guarantees”

The book lists three properties (Lehmann and Casella, 1998; Efron and Hastie, 2016):

  1. Asymptotic consistency. The MLE converges to the true value in the limit of infinitely many observations, plus a random error that is approximately normal.
  2. The error’s variance decays as 1/N1/N.
  3. And the caveat: “the size of the samples necessary to achieve these properties can be quite large.”

Then the warning that motivates the next page: “Especially, in the ‘small’ data regime, maximum likelihood estimation can lead to overfitting.”

Measured on a three-parameter model with known truth:

NNmean squared errorN×N \times error
10100.150537550.150537551.5053751.505375
40400.024531470.024531470.9812590.981259
1601600.005862500.005862500.9380000.938000
6406400.001459830.001459830.9342900.934290
256025600.000370950.000370950.9496350.949635
10240102400.000090300.000090300.9246830.924683

The right column is roughly constant from N=40N = 40 onward, which is the 1/N1/N claim. At N=10N = 10 it is 1.511.51 — noticeably above the asymptote, which is the “samples necessary can be quite large” caveat showing up at the small end.

Derive the MLE for the mean of a Gaussian, the smallest complete case.

Model: ynN(θ,σ2)y_n \sim \mathcal{N}(\theta, \sigma^2) with σ\sigma known, and observations y=(1.2, 2.1, 1.7)y = (1.2,\ 2.1,\ 1.7).

Step 1: the negative log-likelihood.

L(θ)=n=13log[12πσ2exp((ynθ)22σ2)]=12σ2n=13(ynθ)2+const\mathcal{L}(\theta) = -\sum_{n=1}^{3}\log\left[\frac{1}{\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(y_n - \theta)^2}{2\sigma^2}\right)\right] = \frac{1}{2\sigma^2}\sum_{n=1}^{3}(y_n - \theta)^2 + \text{const}

Step 2: differentiate and set to zero.

dLdθ=1σ2n=13(ynθ)=0n=13yn=3θθ=13n=13yn\frac{\mathrm{d}\mathcal{L}}{\mathrm{d}\theta} = -\frac{1}{\sigma^2}\sum_{n=1}^{3}(y_n - \theta) = 0 \quad\Longrightarrow\quad \sum_{n=1}^{3} y_n = 3\theta \quad\Longrightarrow\quad \theta = \frac{1}{3}\sum_{n=1}^{3}y_n

The maximum likelihood estimate of a Gaussian mean is the sample mean. With these numbers:

θ^=1.2+2.1+1.73=5.03=1.666667\hat\theta = \frac{1.2 + 2.1 + 1.7}{3} = \frac{5.0}{3} = 1.666667

Measured by a grid search over the likelihood: 1.6666551.666655, differing only by the grid spacing.

Step 3: check it is a minimum. d2Ldθ2=3σ2>0\dfrac{\mathrm{d}^2\mathcal{L}}{\mathrm{d}\theta^2} = \dfrac{3}{\sigma^2} > 0. Positive for every σ\sigma, so it is a minimum of L\mathcal{L} and hence a maximum of the likelihood.

Step 4: notice what σ\sigma did. It appears in L\mathcal{L}, it appears in the second derivative, and it cancels completely from the answer. That is the same cancellation as Equation 8.18’s: with σ\sigma known and constant, it scales the objective without moving its minimiser. The MLE for the mean is the sample mean whatever the noise level is.

The two readings are much easier to feel than to read about:

sketch One formula, two readings p5.js
The top panel fixes theta and varies y, giving a density that integrates to one. The bottom panel fixes the data and varies theta, giving the likelihood — which does not. Drag theta and watch the marker move along the likelihood curve as the density slides.
mle.py
import numpy as np
 
SIGMA = 0.35
 
def make(n, seed, noise=SIGMA):
    rng = np.random.default_rng(seed)
    x = np.sort(rng.uniform(-3, 3, n))
    return x, np.sin(1.4 * x) + 0.3 * x + noise * rng.standard_normal(n)
 
def design(x, deg):
    return np.vander(x / 3.0, deg + 1, increasing=True)
 
x, y = make(25, seed=3)
Phi = design(x, 3)
N = len(y)
 
def empirical_risk(th):
    """Equation 8.7."""
    return float(np.mean((y - Phi @ th) ** 2))
 
def nll(th):
    """Equation 8.18d, written exactly as the book leaves it."""
    r = y - Phi @ th
    return float(r @ r / (2 * SIGMA ** 2)
                 - N * np.log(1.0 / np.sqrt(2 * np.pi * SIGMA ** 2)))
 
# --- the two objectives have the same minimiser ---------------------------
th_ls = np.linalg.lstsq(Phi, y, rcond=None)[0]
 
# minimise the NLL from a different start by Newton's method
th = np.zeros(Phi.shape[1])
H = Phi.T @ Phi / SIGMA ** 2
for _ in range(50):
    g = -Phi.T @ (y - Phi @ th) / SIGMA ** 2
    th = th - np.linalg.solve(H, g)
 
print("least-squares theta :", np.round(th_ls, 6).tolist())
print("NLL-minimising theta:", np.round(th, 6).tolist())
print(f"max |difference|    : {np.abs(th - th_ls).max():.3e}")
 
# --- and they differ by an affine transformation --------------------------
const = -N * np.log(1.0 / np.sqrt(2 * np.pi * SIGMA ** 2))
slope = N / (2 * SIGMA ** 2)
print(f"\nEquation 8.18d says L = (1/(2 sigma^2)) sum r^2 + const")
print(f"  in terms of R_emp that is  L = {slope:.6f} * R_emp + "
      f"({const:.6f})")
print(f"\n{'theta tried':>36} {'R_emp':>12} {'L':>14} {'predicted L':>14}")
for scale in (0.0, 0.5, 1.0, 1.5):
    t = scale * th_ls
    pred = slope * empirical_risk(t) + const
    print(f"{str(np.round(t, 3).tolist()):>36} {empirical_risk(t):>12.6f} "
          f"{nll(t):>14.6f} {pred:>14.6f}")
print("the last two columns agree, so the NLL is an affine function of R_emp")
print("and a positive multiple plus a constant cannot move an argmin.")
 
# --- the likelihood is not a distribution over theta ---------------------
print("\nThe likelihood is NOT a distribution over theta:")
obs = np.array([1.2, 2.1, 1.7])
sig = 0.8
ths = np.linspace(-10, 12, 400001)
lik = np.ones_like(ths)
for o in obs:
    lik *= np.exp(-0.5 * ((o - ths) / sig) ** 2) / (sig * np.sqrt(2 * np.pi))
print(f"  three observations {obs.tolist()}, sigma = {sig}")
print(f"  area under the likelihood in theta: {np.trapezoid(lik, ths):.6f}")
print(f"  argmax at theta = {ths[int(np.argmax(lik))]:.6f}, "
      f"sample mean = {obs.mean():.6f}")
ys = np.linspace(-12, 14, 400001)
dens = np.exp(-0.5 * ((ys - 2.0) / sig) ** 2) / (sig * np.sqrt(2 * np.pi))
print(f"  area under p(y | theta=2) in y:     {np.trapezoid(dens, ys):.6f}")
print("  one integrates to 1, the other does not. Only one is a density.")
 
# --- Section 8.3.2's remark: the error variance decays as 1/N -----------
print("\nThe MLE error variance decays as 1/N:")
true_theta = np.array([0.4, 1.2, -0.7])
rng = np.random.default_rng(0)
print(f"{'N':>8} {'mean sq error':>16} {'N x error':>12}")
for n in (10, 40, 160, 640, 2560, 10240):
    trials = 2000
    errs = np.empty(trials)
    for t in range(trials):
        xs = rng.uniform(-2, 2, n)
        A = np.vander(xs, 3, increasing=True)
        ys_ = A @ true_theta + 0.5 * rng.standard_normal(n)
        thn = np.linalg.lstsq(A, ys_, rcond=None)[0]
        errs[t] = np.sum((thn - true_theta) ** 2)
    m = errs.mean()
    print(f"{n:>8} {m:>16.8f} {n * m:>12.6f}")
print("N times the error is roughly constant, which is the 1/N claim.")
text
least-squares theta : [-0.116506, 3.633144, 0.492278, -4.086057]
NLL-minimising theta: [-0.116506, 3.633144, 0.492278, -4.086057]
max |difference|    : 1.776e-15
 
Equation 8.18d says L = (1/(2 sigma^2)) sum r^2 + const
  in terms of R_emp that is  L = 102.040816 * R_emp + (-3.272090)
 
                         theta tried        R_emp              L    predicted L
              [-0.0, 0.0, 0.0, -0.0]     0.998583      98.624110      98.624110
      [-0.058, 1.817, 0.246, -2.043]     0.359425      33.403965      33.403965
      [-0.117, 3.633, 0.492, -4.086]     0.146373      11.663917      11.663917
       [-0.175, 5.45, 0.738, -6.129]     0.359425      33.403965      33.403965
the last two columns agree, so the NLL is an affine function of R_emp
and a positive multiple plus a constant cannot move an argmin.
 
The likelihood is NOT a distribution over theta:
  three observations [1.2, 2.1, 1.7], sigma = 0.8
  area under the likelihood in theta: 0.104496
  argmax at theta = 1.666655, sample mean = 1.666667
  area under p(y | theta=2) in y:     1.000000
  one integrates to 1, the other does not. Only one is a density.
 
The MLE error variance decays as 1/N:
       N    mean sq error    N x error
      10       0.15053755     1.505375
      40       0.02453147     0.981259
     160       0.00586250     0.938000
     640       0.00145983     0.934290
    2560       0.00037095     0.949635
   10240       0.00009030     0.924683
N times the error is roughly constant, which is the 1/N claim.
figure One formula and two different objects matplotlib
Two panels. Left, three Gaussian densities over y for three different values of theta, with the three fixed observations marked as vertical lines. Right, the likelihood as a function of theta, a single peaked curve with its maximum at the sample mean, annotated that its area is 0.104496 rather than one. Two panels. Left, three Gaussian densities over y for three different values of theta, with the three fixed observations marked as vertical lines. Right, the likelihood as a function of theta, a single peaked curve with its maximum at the sample mean, annotated that its area is 0.104496 rather than one.
Fix theta and vary y and you have a distribution that integrates to one. Fix y and vary theta and you have the likelihood, whose area here is 0.104496. The three squares on the right are the same three curves from the left, read as three points on one function.
figure Equation 8.18: Gaussian maximum likelihood is least squares matplotlib
Two panels. Left, the empirical risk and the negative log-likelihood plotted against the slope coefficient on twin axes, their minima at exactly the same place. Right, the negative log-likelihood plotted directly against the empirical risk, falling exactly on a straight line of slope 102.04 and intercept minus 3.27. Two panels. Left, the empirical risk and the negative log-likelihood plotted against the slope coefficient on twin axes, their minima at exactly the same place. Right, the negative log-likelihood plotted directly against the empirical risk, falling exactly on a straight line of slope 102.04 and intercept minus 3.27.
The two objectives differ by a positive multiple and a constant, and neither operation can move a minimiser. Plotting one against the other gives a straight line to within floating-point error.
figure Section 8.3.2's remark, checked matplotlib
Three panels. Left, the mean squared error of the estimate against N on log-log axes, lying along a one-over-N reference line. Middle, a histogram of standardised errors overlaid with a standard normal density, skew and excess kurtosis both near zero. Right, training and expected risk against polynomial degree for only twelve data points, the expected risk rising steeply. Three panels. Left, the mean squared error of the estimate against N on log-log axes, lying along a one-over-N reference line. Middle, a histogram of standardised errors overlaid with a standard normal density, skew and excess kurtosis both near zero. Right, training and expected risk against polynomial degree for only twelve data points, the expected risk rising steeply.
N times the mean squared error is roughly constant from N equals 40 onward, confirming the one-over-N decay. The error distribution is close to normal. But with only twelve points the same estimator overfits badly, which is the remark's closing warning.

The first figure is the distinction the whole section turns on. Both panels are built from the same formula and the same three observations. On the left, θ\boldsymbol\theta is fixed at three different values and yy runs along the axis: three bell curves, each integrating to 11, each a legitimate probability density over data. The green lines are the observations, and you can see each curve assigning them different densities.

On the right, the observations are fixed and θ\boldsymbol\theta runs along the axis. The three coloured squares are the same three settings — the product of the three green dots’ heights, for each curve. Sweeping θ\boldsymbol\theta traces out the likelihood.

Now the part that matters: the annotation says the area under the right-hand curve is 0.1044960.104496. It is not 11, it was never going to be 11, and nothing in the construction normalises it. The likelihood is a function of θ\boldsymbol\theta, not a distribution over θ\boldsymbol\theta. Phrases like “the most likely parameter” are convenient and slightly wrong; the object that is a distribution over θ\boldsymbol\theta is the posterior, and getting it requires the prior of §8.3.2.

The second figure turns “analogous” into “identical”. The left panel slices both objectives along one coordinate. The blue curve (RempR_{\text{emp}}) and the green curve (L\mathcal{L}) are on different axes with different scales — but their minima are at the same place, to six decimals.

The right panel is why. Plot L\mathcal{L} directly against RempR_{\text{emp}} and you get a straight line: slope N/(2σ2)=102.040816N/(2\sigma^2) = 102.040816, intercept 3.272090-3.272090, with a maximum deviation at the 101410^{-14} level. An affine map with positive slope is monotone, so it preserves ordering exactly — every θ\boldsymbol\theta that one objective prefers, the other prefers too.

This is stronger than an analogy and it is worth being clear about the scope. It holds for a Gaussian likelihood with known, constant variance. Change the noise model and the correspondence breaks: a Laplace likelihood gives absolute loss, not squared. Let σ\sigma depend on x\mathbf{x} and the sum becomes weighted least squares. The general statement is that choosing a noise distribution is choosing a loss function — and §8.2’s freedom not to specify one is exactly the freedom §8.3 gives up.

The third figure checks the three claims and the caveat. The left panel plots the mean squared error against NN on log-log axes with a pure 1/N1/N reference. The measured products N×errorN \times \text{error} run 1.5051.505, 0.9810.981, 0.9380.938, 0.9340.934, 0.9500.950, 0.9250.925 — settled by N=40N = 40 and constant thereafter. The one visible outlier is N=10N = 10, sitting 60%60\% above the asymptote, which is the book’s “the size of the samples necessary to achieve these properties can be quite large” made visible at the small end.

The middle panel checks “approximately normal”: standardised errors against a standard normal, with measured skew and excess kurtosis both near zero. For a linear-Gaussian model this is exact rather than asymptotic, which is why the agreement is so clean — a nonlinear model would show visible departure at small NN.

The right panel is the warning, and it is the bridge to page 805. With N=12N = 12 the same estimator, with no bug and no misconfiguration, produces an expected risk that climbs steeply with model complexity. The MLE has no mechanism to prevent this: it maximises fit to the data it has, full stop. §8.2.3 added a penalty to fix that; §8.3.2 adds a prior, and page 805 measures that they are the same repair.

empirical risk minimization, §8.2maximum likelihood, §8.3.1
the object minimisedRempR_{\text{emp}}, Eq 8.6L\mathcal{L}, Eq 8.14
what you must specifya loss functiona noise distribution
the Gaussian casesquared lossthe same objective, scaled
measured relationL=102.040816Remp3.272090\mathcal{L} = 102.040816\,R_{\text{emp}} - 3.272090
minimisers agree to1.8×10151.8\times10^{-15}
regularisation appears asa penalty term, §8.2.3a prior, §8.3.2
outputa point estimatea point estimate
can express predictive uncertaintynoyes, via the noise model
noise modelthe loss it implies
Gaussian, constant σ\sigmasquared loss
Gaussian, σ(x)\sigma(\mathbf{x})weighted squared loss
Laplaceabsolute loss
Bernoullicross-entropy / logistic loss
pch.quizTag Do you know what the likelihood is and is not?
  1. Why does the likelihood in the worked example integrate to 0.104496 rather than 1?

    pch.quizShowAnswer

    B — Because it is a function of theta and was never normalised in theta — it is not a density over parameters — The density p(y | theta) integrates to exactly 1.000000 over y, because that is what a density does. The likelihood is the same formula read along the other axis, and nothing normalises it there. Turning it into a distribution over theta requires a prior, which is Section 8.3.2.

  2. Equation 8.18 shows the Gaussian negative log-likelihood equals (N / 2 sigma squared) times the empirical risk, plus a constant. What follows?

    pch.quizShowAnswer

    B — They have identical minimisers, because a positive multiple plus a constant cannot move an argmin — measured agreement 1.8e-15 — An affine map with positive slope is strictly monotone, so it preserves ordering exactly: every theta one objective prefers, the other prefers too. Section 8.2 and Section 8.3 are the same objective in different vocabulary — for this noise model.

  3. Does maximum likelihood always reduce to least squares?

    pch.quizShowAnswer

    B — No — only for a Gaussian likelihood with known constant variance. A Laplace likelihood gives absolute loss, and an input-dependent sigma gives weighted least squares — The cancellation in Equation 8.18 depends on the specific form of the Gaussian and on sigma being constant. The general statement is that choosing a noise distribution IS choosing a loss function — which is exactly the specification Section 8.2 was free to skip.

  4. Why is the negative sign in Equation 8.14 there?

    pch.quizShowAnswer

    B — It is a historical artifact: we want to maximise likelihood, but optimisation literature studies minimisation — The book says exactly this. Negation reverses the ordering once, so argmax of p equals argmin of L with no approximation. The logarithm, by contrast, IS doing work — it turns a product that underflows into a sum that does not.

  5. N times the MLE's mean squared error measured 1.505 at N = 10 and settled near 0.93 from N = 40 onward. What does that show?

    pch.quizShowAnswer

    B — The 1 over N decay is confirmed asymptotically, and N = 10 is visibly outside the regime where the asymptotic properties hold — A constant product means error proportional to one over N, which is the book's claim. The N = 10 value sitting 60 percent above the asymptote is the book's own caveat — that the sample sizes needed can be quite large — showing up at the small end, and it is why Section 8.3.2 exists.

Exercise 2 – The likelihood is not a density over theta

Section titled “Exercise 2 – The likelihood is not a density over theta”

Exercise 3 – Equation 8.18, the affine relation

Section titled “Exercise 3 – Equation 8.18, the affine relation”

Exercise 4 – Both routes reach the same theta

Section titled “Exercise 4 – Both routes reach the same theta”

Exercise 5 – The 1/N decay, and where it fails

Section titled “Exercise 5 – The 1/N decay, and where it fails”
  • Section 8.3’s own mapping: the likelihood is analogous to a loss function, and a prior is analogous to regularisation. Measured, “analogous” understates it — for a Gaussian the two are affine transforms of each other.
  • Equation 8.14 is minus the log of the likelihood. The log turns an underflowing product into a sum; the negative sign is a historical artifact of the minimisation convention. Neither moves the argmin.
  • p(x given theta) is one formula and two objects. Fix theta and vary x: a distribution over data, integrating to one. Fix x and vary theta: the likelihood, which does not.
  • Measured: the likelihood integrated to 0.104496 over theta while the density integrated to 1.000000 over y. “The most likely theta” is a figure of speech; the object that IS a distribution over theta is the posterior.
  • Theta on the right of the conditioning bar is still the variable. The book warns about this explicitly — the bar means “for this setting of”, not “having observed”.
  • Equations 8.15 to 8.17: a Gaussian conditional on the linear prediction, then independence turns the product into a sum of logs.
  • Example 8.5’s punchline: the Gaussian NLL is (N over 2 sigma squared) times the empirical risk plus a constant. Measured with N = 25 and sigma = 0.35, that is 102.040816 times R_emp minus 3.272090, and the two minimisers agree to 1.8e-15.
  • A positive multiple plus a constant cannot move an argmin, so Section 8.2 and Section 8.3 are the same objective in different vocabulary.
  • But only for THIS noise model. Laplace gives absolute loss; an input-dependent sigma gives weighted least squares. Choosing a noise distribution IS choosing a loss function — the specification Section 8.2 was free to skip.
  • Sigma cancels from the answer. In the worked example it appears in the NLL and in its second derivative and vanishes from the estimate: the MLE of a Gaussian mean is the sample mean at any noise level.
  • Three asymptotic properties: consistency, approximately normal error, and error variance decaying as one over N. Measured, N times the error settles near 0.93 from N = 40 onward.
  • And one caveat that bites. At N = 10 the product was 1.505, 60 percent above the asymptote, and with N = 12 the MLE overfits badly. The book’s closing line is that in the small-data regime maximum likelihood can lead to overfitting — which is what the next page fixes.

Next: add a prior, and discover it was the penalty term all along. MAP Estimation and Model Fitting

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading