Skip to content

Probabilistic Modeling and Inference

Page 805 ended on the book’s own limit: MAP “still only produces a point estimate of the parameters.” You write down an entire posterior distribution and then keep the location of its peak.

This page keeps the rest. And it measures what that buys, because the difference is not philosophical: a nominal 95% interval built from the full posterior achieves 0.9506, 0.9501 and 0.9498 coverage across three regions, while the plug-in interval built from the point estimate achieves 0.9287, 0.5701 and 0.1796.

  • Why §8.4.1 says a probabilistic model is specified by the joint distribution — and what “only the joint distribution has this property” means.
  • Equation 8.22, and the integral in its denominator that MAP was allowed to skip.
  • Equation 8.23: predictions become an average over all plausible parameters, measured to hold 95% coverage where the plug-in falls to 0.1796.
  • The book’s own comparison: estimation is an optimization problem, inference is an integration problem — and when the difference stops mattering (measured: at N=10000N = 10000 the two intervals differ by a factor of 1.0001131.000113).
  • §8.4.3 latent variables, and Equation 8.25’s insistence that the likelihood “must not depend on” z\mathbf{z}.
  • The honest limit, measured: on the chapter’s misspecified sine data, the full predictive reaches only 0.89080.8908. Bayesian inference quantifies doubt about θ\boldsymbol\theta, not doubt about the model class.

Intuition: the difference between a guess and a guess with a margin

Section titled “Intuition: the difference between a guess and a guess with a margin”

You fit a model and it predicts 137.46137.46. Two follow-up questions:

  1. Would you bet on it?
  2. Would you bet on it for an input nothing like the training data?

A point estimate cannot answer either. It hands back one number, and any interval you attach comes from the noise term σ2\sigma^2 alone — a constant, the same width at the centre of the data and a hundred units outside it. That is the plug-in predictive p(xθ)p(x \mid \boldsymbol\theta^*), and it is structurally incapable of saying “I don’t know”.

The posterior can. It holds many parameter vectors, all consistent with the data. Where the data pins them down, they agree and the prediction is tight. Where the data says nothing, they disagree wildly and the prediction is wide. That disagreement is the uncertainty, and Equation 8.23 is the instruction to report it.

The price is an integral. Optimization finds a peak; integration sums over everything. That is the book’s whole comparison in one line.

diagram Two problems, two costs mermaid

The book’s framing: probabilistic models “represent the uncertain aspects of an experiment as probability distributions”, and the benefit is “a unified and consistent set of tools from probability theory for modeling, inference, prediction, and model selection” — one toolkit for all four jobs.

The central object is the joint distribution p(x,θ)p(\mathbf{x}, \boldsymbol\theta) of the observed variables and the hidden parameters, because it “encapsulates information from the following”:

what you wanthow the joint gives itwhich rule (§6.3)
the prior and the likelihoodthey are its factorsproduct rule
the marginal likelihood p(x)p(\mathbf{x})integrate out θ\boldsymbol\thetasum rule
the posteriordivide the joint by the marginal

And then the sentence that justifies the whole framing:

Only the joint distribution has this property. Therefore, a probabilistic model is specified by the joint distribution of all its random variables.

That is a definition, not a remark. A probabilistic model is a joint distribution. Everything else — prior, likelihood, posterior, evidence — is something you derive from it by applying a rule of probability. This is why §8.5’s graphical language is about the joint and nothing else.

For a dataset X\mathcal{X}, a parameter prior p(θ)p(\boldsymbol\theta), and a likelihood function, the posterior is

p(θX)=p(Xθ)p(θ)p(X),p(X)=p(Xθ)p(θ)dθp(\boldsymbol\theta \mid \mathcal{X}) = \frac{p(\mathcal{X} \mid \boldsymbol\theta)\,p(\boldsymbol\theta)}{p(\mathcal{X})}, \qquad p(\mathcal{X}) = \int p(\mathcal{X} \mid \boldsymbol\theta)\,p(\boldsymbol\theta)\,d\boldsymbol\theta

The key idea, in the book’s words, is “to exploit Bayes’ theorem to invert the relationship between the parameters θ\boldsymbol\theta and the data X\mathcal{X}. The likelihood runs parameters → data; the posterior runs data → parameters.

Note the denominator. Page 805’s MAP estimation could drop p(X)p(\mathcal{X}) because it is constant in θ\boldsymbol\theta. Bayesian inference cannot: it needs the posterior normalised, so it needs that integral. This one difference is the source of essentially every practical difficulty on this page.

Equation 8.23: predictions stop depending on the parameters

Section titled “Equation 8.23: predictions stop depending on the parameters”

With a distribution on the parameters, the prediction becomes

p(x)=p(xθ)p(θ)dθ=Eθ ⁣[p(xθ)]p(\mathbf{x}) = \int p(\mathbf{x} \mid \boldsymbol\theta)\,p(\boldsymbol\theta)\,d\boldsymbol\theta = \mathbb{E}_{\boldsymbol\theta}\!\left[p(\mathbf{x} \mid \boldsymbol\theta)\right]

The parameters have been marginalised out. The book: “the prediction is an average over all plausible parameter values θ\boldsymbol\theta, where the plausibility is encapsulated by the parameter distribution.”

For a Gaussian model this has a closed form worth memorising. At an input ϕ\boldsymbol\phi:

mean=ϕmN,variance=σ2noise+ϕΣNϕnot knowing θ\text{mean} = \boldsymbol\phi^\top\mathbf{m}_N, \qquad \text{variance} = \underbrace{\sigma^2}_{\text{noise}} + \underbrace{\boldsymbol\phi^\top\boldsymbol\Sigma_N\boldsymbol\phi}_{\text{not knowing }\boldsymbol\theta}

The mean is the same as the plug-in prediction. Only the variance differs — and only by that second term, which is exactly what the point estimate discarded.

Why it matters: the book’s argument, measured

Section titled “Why it matters: the book’s argument, measured”

The book’s case is about decisions:

Focusing solely on some statistic of the posterior distribution (such as the parameter θ\boldsymbol\theta^* that maximizes the posterior) leads to loss of information, which can be critical in a system that uses the prediction p(xθ)p(\mathbf{x} \mid \boldsymbol\theta^*) to make decisions.

To measure “critical”, I drew θ\boldsymbol\theta from the prior, drew data from the model, and counted how often a nominal 95%95\% interval actually contained the held-out value — 40004000 trials, 160,000160{,}000 test points per region.

This is the setting where the Bayesian interval is guaranteed correct: the prior is the truth. That guarantee is what is being verified, and it holds to three decimal places.

Estimation against inference, as the book puts it

Section titled “Estimation against inference, as the book puts it”
parameter estimation (§8.3)Bayesian inference (§8.4.2)
what you get“a consistent point estimate” θ\boldsymbol\theta^*“a (posterior) distribution”
computational problemoptimizationintegration
making a prediction“straightforward”“require solving another integration problem”
prior knowledgenot easily incorporated“a principled way”
structural/side informationhard“not easily done” the other way
uncertainty propagationnonevaluable for “risk assessment and exploration”

The book cites the payoff in “data-efficient learning” (Deisenroth et al., 2015; Kamthe and Deisenroth, 2018) — knowing what you don’t know is what tells you where to look next.

The book is direct about the cost:

If we do not choose a conjugate prior on the parameters (§6.6.1), the integrals in (8.22) and (8.23) are not analytically tractable, and we cannot compute the posterior, the predictions, or the marginal likelihood in closed form.

Everything on this page is computed exactly because the prior is conjugate. Step outside that and you need approximations. The book’s list, grouped:

kindmethods
stochasticMarkov chain Monte Carlo (Gilks et al., 1996)
deterministicthe Laplace approximation; variational inference (Jordan et al., 1999; Blei et al., 2017); expectation propagation (Minka, 2001a)

And the applications where the cost was judged worth paying: “large-scale topic modeling, click-through-rate prediction, data-efficient reinforcement learning in control systems, online ranking systems, and large-scale recommender systems”, plus Bayesian optimization as a “generic tool” for “efficient search of meta parameters”.

Latent variables z\mathbf{z} are “different from the model parameters θ\boldsymbol\theta as they do not parametrize the model explicitly”. They exist because they “may describe the data-generating process, thereby contributing to the interpretability of the model” and because they “often simplify the structure of the model” — usually with fewer parameters, not more.

The generative direction is Equation 8.24:

p(xθ,z)p(\mathbf{x} \mid \boldsymbol\theta, \mathbf{z})

and since z\mathbf{z} is latent, it gets a prior p(z)p(\mathbf{z}).

Learning then proceeds in two steps. First compute a likelihood that does not mention z\mathbf{z}; second, feed it to §8.3 or §8.4.2 unchanged. The first step is Equation 8.25:

p(xθ)=p(xθ,z)p(z)dzp(\mathbf{x} \mid \boldsymbol\theta) = \int p(\mathbf{x} \mid \boldsymbol\theta, \mathbf{z})\,p(\mathbf{z})\,d\mathbf{z}

with the book’s insistence in the margin: “Note that the likelihood must not depend on the latent variables z\mathbf{z}, but it is only a function of the data x\mathbf{x} and the model parameters θ\boldsymbol\theta.”

The book lists where this pays: “principal component analysis for dimensionality reduction (Chapter 10), Gaussian mixture models for density estimation (Chapter 11), hidden Markov models or dynamical systems for time-series modeling, and meta learning and task generalization”. It also gives the warning up front: “learning in latent-variable models is generally hard, as we will see in Chapter 11”, with the EM algorithm (Dempster et al., 1977) as the principled route via maximum likelihood.

what you wantequationwhat it costs
p(θX)p(\boldsymbol\theta \mid \mathcal{X}), parameters8.26needs Eq. 8.25’s integral over z\mathbf{z} first
p(zX)p(\mathbf{z} \mid \mathcal{X}), latents8.27needs p(Xz)=p(Xz,θ)p(θ)dθp(\mathcal{X} \mid \mathbf{z}) = \int p(\mathcal{X} \mid \mathbf{z}, \boldsymbol\theta)p(\boldsymbol\theta)d\boldsymbol\theta
both at once“not possible in general”
p(zX,θ)p(\mathbf{z} \mid \mathcal{X}, \boldsymbol\theta), latents given parameters8.28“a quantity that is easier to compute”

The last row is the practical compromise, and it is not an accident that Chapters 10 and 11 compute exactly Equation 8.28 for PCA and for Gaussian mixture models. When both integrals are intractable, you condition on one instead of integrating it.

Ghahramani (2015) gives “a short review of probabilistic models in machine learning”. Moustaki et al. (2015) and Paquet (2008) cover Bayesian inference in latent-variable models. And the book flags a field built around automating all of this:

Several programming languages have been proposed that aim to treat the variables defined in software as random variables corresponding to probability distributions. The objective is to be able to write complex functions of probability distributions, while under the hood the compiler automatically takes care of the rules of Bayesian inference. This rapidly changing field is called probabilistic programming.

The Gaussian mean again — the smallest case where you can watch a posterior appear.

Model: ynN(θ,σ2)y_n \sim \mathcal{N}(\theta, \sigma^2), NN observations, prior θN(0,τ2)\theta \sim \mathcal{N}(0, \tau^2).

Step 1: the posterior is Gaussian, so find its two numbers. Collect the θ\theta-dependent part of the negative log-posterior:

12σ2n(ynθ)2+θ22τ2=12θ2(Nσ2+1τ2)θNyˉσ2+const\frac{1}{2\sigma^2}\sum_n (y_n - \theta)^2 + \frac{\theta^2}{2\tau^2} = \frac{1}{2}\theta^2\left(\frac{N}{\sigma^2} + \frac{1}{\tau^2}\right) - \theta\,\frac{N\bar{y}}{\sigma^2} + \text{const}

A quadratic in θ\theta is a Gaussian. Matching to 12σN2(θmN)2\frac{1}{2\sigma_N^2}(\theta - m_N)^2:

 1σN2=Nσ2+1τ2,mN=σN2Nyˉσ2 \boxed{\ \frac{1}{\sigma_N^2} = \frac{N}{\sigma^2} + \frac{1}{\tau^2}, \qquad m_N = \sigma_N^2\,\frac{N\bar{y}}{\sigma^2}\ }

Step 2: read the precision. Precisions add: the data contributes N/σ2N/\sigma^2 and the prior contributes 1/τ21/\tau^2. Each observation adds exactly 1/σ21/\sigma^2 of certainty, which is why the posterior sd falls like 1/N1/\sqrt{N}.

Step 3: check mNm_N against page 805. Substituting σN2\sigma_N^2:

mN=Nyˉ/σ2N/σ2+1/τ2=NN+σ2/τ2yˉm_N = \frac{N\bar{y}/\sigma^2}{N/\sigma^2 + 1/\tau^2} = \frac{N}{N + \sigma^2/\tau^2}\,\bar{y}

That is page 805’s MAP estimate exactly. For a Gaussian, the posterior mean and the MAP point coincide — so nothing about the location was lost. Everything lost was σN2\sigma_N^2.

Step 4: build the predictive, Equation 8.23. A new observation is ynew=θ+ϵy_{\text{new}} = \theta + \epsilon with θN(mN,σN2)\theta \sim \mathcal{N}(m_N, \sigma_N^2) and ϵN(0,σ2)\epsilon \sim \mathcal{N}(0, \sigma^2) independent. A sum of independent Gaussians adds variances:

p(ynewX)=N ⁣(mN, σ2+σN2)p(y_{\text{new}} \mid \mathcal{X}) = \mathcal{N}\!\left(m_N,\ \sigma^2 + \sigma_N^2\right)

Step 5: compare with the plug-in. The plug-in predictive is N(mN,σ2)\mathcal{N}(m_N, \sigma^2) — same centre, and missing σN2\sigma_N^2 entirely. The ratio of interval widths is

1+σN2σ2=1+1N+σ2/τ2\sqrt{1 + \frac{\sigma_N^2}{\sigma^2}} = \sqrt{1 + \frac{1}{N + \sigma^2/\tau^2}}

which tends to 11 as NN grows and blows up as N0N \to 0. Optimization and integration agree in the limit of infinite data and disagree most exactly when you have least.

sketch One point, or the whole posterior p5.js
A Gaussian posterior over the mean of a small dataset. Drag the sample size and the prior width; watch the posterior narrow, the MAP point stay at its centre, and the gap between the plug-in predictive and the full predictive open and close.
bayesian_inference.py
import numpy as np
 
SIGMA, TAU2, D = 0.35, 1.0, 4
Z = 1.959963984540054
 
def make(n, seed):
    rng = np.random.default_rng(seed)
    x = np.sort(rng.uniform(-3, 3, n))
    return x, np.sin(1.4 * x) + 0.3 * x + SIGMA * rng.standard_normal(n)
 
def design(x, deg=3):
    return np.vander(np.asarray(x, float) / 3.0, deg + 1, increasing=True)
 
x, y = make(25, seed=3)
Phi = design(x)
N = len(y)
 
# --- Equation 8.22: the exact posterior, by conjugacy (Section 6.6.1) ---
Sigma = np.linalg.inv(Phi.T @ Phi / SIGMA ** 2 + np.eye(D) / TAU2)
mean = Sigma @ Phi.T @ y / SIGMA ** 2
 
# the MAP estimate of Section 8.3.2, for comparison
mapest = np.linalg.solve(Phi.T @ Phi / SIGMA ** 2 + np.eye(D) / TAU2,
                         Phi.T @ y / SIGMA ** 2)
print("=== 1. the point estimate is the posterior MEAN ===")
print(f"posterior mean : {np.round(mean, 6).tolist()}")
print(f"MAP estimate   : {np.round(mapest, 6).tolist()}")
print(f"max difference : {np.abs(mean - mapest).max():.2e}")
print("MAP is not wrong -- it is incomplete. What it discarded:")
print(f"posterior sd   : {np.round(np.sqrt(np.diag(Sigma)), 6).tolist()}")
 
# --- Equation 8.23: the predictive averages over theta ------------------
print("\n=== 2. the variance of Equation 8.23 splits in two ===")
print(f"{'x':>6} {'noise':>10} {'parameters':>12} {'total':>10} {'share':>8}")
for xs in (0.0, 2.0, 3.0, 4.0, 5.0):
    q = design([xs])[0]
    pv = float(q @ Sigma @ q)
    print(f"{xs:>6.1f} {SIGMA**2:>10.6f} {pv:>12.6f} {SIGMA**2+pv:>10.6f} "
          f"{pv/(SIGMA**2+pv):>7.1%}")
print("inside the data the noise dominates; outside it the parameters do.")
 
# --- does it matter? calibration, with the prior matched to the truth ---
print("\n=== 3. coverage of a nominal 95% interval, 4000 trials ===")
rng = np.random.default_rng(11)
regions = (("interpolation", -3.0, 3.0), ("mild extrapolation", 3.0, 5.0),
           ("far extrapolation", 5.0, 7.0))
hp = {r[0]: 0 for r in regions}; hf = dict(hp); wf = {r[0]: 0.0 for r in regions}
tot = dict(hp)
for _ in range(4000):
    th = np.sqrt(TAU2) * rng.standard_normal(D)      # theta from the prior
    xtr = np.sort(rng.uniform(-3, 3, 25))
    P = design(xtr)
    ytr = P @ th + SIGMA * rng.standard_normal(25)   # data from the model
    C = np.linalg.inv(P.T @ P / SIGMA ** 2 + np.eye(D) / TAU2)
    m = C @ P.T @ ytr / SIGMA ** 2
    for name, lo, hi in regions:
        xt = rng.uniform(lo, hi, 40)
        Pt = design(xt)
        yt = Pt @ th + SIGMA * rng.standard_normal(len(xt))
        mu = Pt @ m
        sd = np.sqrt(SIGMA ** 2 + np.einsum("ij,jk,ik->i", Pt, C, Pt))
        hp[name] += int(np.sum(np.abs(yt - mu) <= Z * SIGMA))
        hf[name] += int(np.sum(np.abs(yt - mu) <= Z * sd))
        wf[name] += float(np.sum(2 * Z * sd))
        tot[name] += len(xt)
print(f"{'region':>20} {'plug-in':>9} {'Eq. 8.23':>9} {'plug width':>11} "
      f"{'full width':>11}")
for name, lo, hi in regions:
    n = tot[name]
    print(f"{name:>20} {hp[name]/n:>9.4f} {hf[name]/n:>9.4f} "
          f"{2*Z*SIGMA:>11.4f} {wf[name]/n:>11.4f}")
print("Equation 8.23 holds 0.95 everywhere. The plug-in interval reports")
print("only the noise, so it collapses the further it goes from the data.")
 
# --- as N grows, the two converge --------------------------------------
print("\n=== 4. optimization and integration converge as N grows ===")
q0 = design([0.0])[0]
print(f"{'N':>7} {'max post. sd':>14} {'width ratio full/plug':>23}")
for n in (5, 10, 25, 100, 1000, 10000):
    xn, yn = make(n, seed=3)
    Pn = design(xn)
    Cn = np.linalg.inv(Pn.T @ Pn / SIGMA ** 2 + np.eye(D) / TAU2)
    v = float(q0 @ Cn @ q0)
    print(f"{n:>7} {np.sqrt(np.diag(Cn)).max():>14.6f} "
          f"{np.sqrt((SIGMA**2+v)/SIGMA**2):>23.6f}")
print("the ratio tends to 1: with enough data a point estimate is fine.")
 
# --- p(X), the term MAP was allowed to drop ----------------------------
print("\n=== 5. the marginal likelihood p(X) ===")
def log_evidence(deg):
    P = design(x, deg)
    C = SIGMA ** 2 * np.eye(N) + TAU2 * (P @ P.T)
    _, ld = np.linalg.slogdet(C)
    return float(-0.5 * (y @ np.linalg.solve(C, y) + ld + N*np.log(2*np.pi)))
evs = [log_evidence(d) for d in range(12)]
kb = int(np.argmax(evs))
print(f"{'degree':>7} {'log p(X)':>11} {'Bayes factor vs best':>22}")
for d in range(12):
    print(f"{d:>7} {evs[d]:>11.4f} {np.exp(evs[d]-evs[kb]):>22.4f}")
print(f"peak at degree {kb}. Degree 11 is only "
      f"{evs[kb]-evs[11]:.4f} nats behind --")
print("the evidence penalises extra capacity but does not forbid it.")
 
# --- Equation 8.25: marginalising out a latent variable ----------------
print("\n=== 6. Equation 8.25: integrating out a latent variable ===")
pz = np.array([0.3, 0.7])
mus, sds = np.array([-1.5, 2.0]), np.array([0.8, 0.5])
def p_x_given_z(xs, k):
    return (np.exp(-0.5 * ((xs - mus[k]) / sds[k]) ** 2)
            / (sds[k] * np.sqrt(2 * np.pi)))
print(f"{'x':>6} {'p(x|z=0)':>11} {'p(x|z=1)':>11} {'p(x) marginal':>15} "
      f"{'p(z=0|x)':>10}")
for xs in (-2.0, 0.0, 1.9, 3.0):
    a, b = p_x_given_z(xs, 0), p_x_given_z(xs, 1)
    marg = pz[0] * a + pz[1] * b
    print(f"{xs:>6.1f} {a:>11.6f} {b:>11.6f} {marg:>15.6f} "
          f"{pz[0]*a/marg:>10.6f}")
grid = np.linspace(-12, 14, 2000001)
dens = pz[0] * p_x_given_z(grid, 0) + pz[1] * p_x_given_z(grid, 1)
print(f"area under the marginal: {np.trapezoid(dens, grid):.8f}")
print("the marginal is a density in x and does not mention z at all,")
print("which is the book's note beneath Equation 8.25.")
text
=== 1. the point estimate is the posterior MEAN ===
posterior mean : [-0.126578, 2.997457, 0.487525, -3.122058]
MAP estimate   : [-0.126578, 2.997457, 0.487525, -3.122058]
max difference : 8.88e-16
MAP is not wrong -- it is incomplete. What it discarded:
posterior sd   : [0.099305, 0.26664, 0.224268, 0.392692]
 
=== 2. the variance of Equation 8.23 splits in two ===
     x      noise   parameters      total    share
   0.0   0.122500     0.009862   0.132362    7.5%
   2.0   0.122500     0.016043   0.138543   11.6%
   3.0   0.122500     0.073805   0.196305   37.6%
   4.0   0.122500     0.543523   0.666023   81.6%
   5.0   0.122500     2.464844   2.587344   95.3%
inside the data the noise dominates; outside it the parameters do.
 
=== 3. coverage of a nominal 95% interval, 4000 trials ===
              region   plug-in  Eq. 8.23  plug width  full width
       interpolation    0.9287    0.9506      1.3720      1.4903
  mild extrapolation    0.5701    0.9501      1.3720      3.8869
   far extrapolation    0.1796    0.9498      1.3720     13.2538
Equation 8.23 holds 0.95 everywhere. The plug-in interval reports
only the noise, so it collapses the further it goes from the data.
 
=== 4. optimization and integration converge as N grows ===
      N   max post. sd   width ratio full/plug
      5       0.821958                1.248213
     10       0.806301                1.116420
     25       0.392692                1.039472
    100       0.239610                1.011311
   1000       0.074293                1.001109
  10000       0.022878                1.000113
the ratio tends to 1: with enough data a point estimate is fine.
 
=== 5. the marginal likelihood p(X) ===
 degree    log p(X)   Bayes factor vs best
      0   -100.7863                 0.0000
      1    -63.2439                 0.0000
      2    -61.4607                 0.0000
      3    -30.7910                 0.4362
      4    -31.0573                 0.3342
      5    -30.0952                 0.8746
      6    -29.9612                 1.0000
      7    -30.2679                 0.7359
      8    -30.1686                 0.8127
      9    -30.2674                 0.7363
     10    -30.2657                 0.7375
     11    -30.2178                 0.7737
peak at degree 6. Degree 11 is only 0.2566 nats behind --
the evidence penalises extra capacity but does not forbid it.
 
=== 6. Equation 8.25: integrating out a latent variable ===
     x    p(x|z=0)    p(x|z=1)   p(x) marginal   p(z=0|x)
  -2.0    0.410201    0.000000        0.123060   1.000000
   0.0    0.085983    0.000268        0.025982   0.992789
   1.9    0.000060    0.782085        0.547478   0.000033
   3.0    0.000000    0.107982        0.075587   0.000000
area under the marginal: 1.00000000
the marginal is a density in x and does not mention z at all,
which is the book's note beneath Equation 8.25.
figure Parameter estimation returns a point; Bayesian inference returns a distribution matplotlib
Two panels. Left, a filled contour map of the joint posterior over two polynomial coefficients with the MAP estimate marked as a single dot at its centre. Right, forty curves drawn from that posterior overlaid on twenty-five data points; the curves coincide where the data lies and fan apart on both sides of it. Two panels. Left, a filled contour map of the joint posterior over two polynomial coefficients with the MAP estimate marked as a single dot at its centre. Right, forty curves drawn from that posterior overlaid on twenty-five data points; the curves coincide where the data lies and fan apart on both sides of it.
The posterior mean equals the MAP estimate to 8.88e-16, so the point estimate is not wrong — it is incomplete. Each of the forty curves explains the same twenty-five points. Their agreement inside the data and disagreement outside it is the uncertainty a point estimate cannot report.
figure Equation 8.23 holds 95 percent coverage everywhere; the plug-in predictive falls to 0.1796 matplotlib
Left, two shaded 95 percent predictive bands over the data: one of constant width, one that widens sharply beyond the data range. Right, a horizontal bar chart of measured coverage in three regions, with the full predictive at about 0.95 in all three and the plug-in falling from 0.9287 to 0.1796. Left, two shaded 95 percent predictive bands over the data: one of constant width, one that widens sharply beyond the data range. Right, a horizontal bar chart of measured coverage in three regions, with the full predictive at about 0.95 in all three and the plug-in falling from 0.9287 to 0.1796.
Measured over 4000 trials with the prior matched to the truth. The plug-in band has width 1.3720 in every region because two times 1.96 times sigma does not depend on where you ask. In far extrapolation it covers the truth 18 percent of the time while claiming 95.
figure Estimation solves an optimization problem; inference solves an integration problem matplotlib
Three panels. Left, the predictive variance on a log scale split into a flat noise band and a parameter-uncertainty band that explodes beyond the data. Middle, the largest posterior standard deviation falling along a one-over-root-N reference line from N equals 5 to 10000. Right, log marginal likelihood against polynomial degree, rising sharply to degree 3 then nearly flat, peaking at degree 6. Three panels. Left, the predictive variance on a log scale split into a flat noise band and a parameter-uncertainty band that explodes beyond the data. Middle, the largest posterior standard deviation falling along a one-over-root-N reference line from N equals 5 to 10000. Right, log marginal likelihood against polynomial degree, rising sharply to degree 3 then nearly flat, peaking at degree 6.
Only the parameter term vanishes with more data — the width ratio falls from 1.248213 at N equals 5 to 1.000113 at N equals 10000. The third panel is the marginal likelihood MAP was allowed to drop, and the quantity Section 8.6 needs in order to choose a model at all.

The first figure is the whole of §8.4 in two panels. On the left, the posterior over two coefficients as a filled density with 68%, 95% and 99% contours, and the MAP estimate as a single dot. The dot sits at the distribution’s centre — measured, the posterior mean and the MAP estimate agree to 8.88×10168.88\times10^{-16}. The point estimate is not in the wrong place. It is simply one dot where there was a distribution.

The right panel shows what that costs. Forty parameter vectors drawn from the posterior, each plotted as a curve. Between 3-3 and 33 they are indistinguishable — the data pins them down. Past 33 they fan apart violently. Every one of those curves explains the same twenty-five observations equally well, and their disagreement is a measurement of ignorance, available for free once you have the covariance and unavailable forever once you have thrown it away.

The second figure measures whether that matters, and the answer is unambiguous. The left panel draws both 95% bands. The yellow one has constant width 1.37201.3720 from one edge of the plot to the other, because 2×1.96×σ2 \times 1.96 \times \sigma contains no reference to xx. The blue one tracks the data and then flares.

The right panel is the measurement: 40004000 trials with θ\boldsymbol\theta drawn from the prior and the data drawn from the model — the only setting in which a Bayesian interval is guaranteed calibrated, so the guarantee is what is being tested. It holds: 0.95060.9506, 0.95010.9501, 0.94980.9498. The plug-in interval gives 0.92870.9287, 0.57010.5701, 0.17960.1796. Far from the data it covers the truth 18% of the time while labelled 95% — not a conservative estimate, a wrong one.

This is what the book means by “loss of information, which can be critical in a system that uses the prediction to make decisions.” A system that trusts a 95% label and receives 18% coverage will make confident decisions on inputs it has never seen, and it will be wrong about nineteen times out of twenty-three more often than it was told to expect.

The third figure is the book’s cost-benefit comparison, panel by panel. The left panel splits the predictive variance. The noise floor σ2=0.1225\sigma^2 = 0.1225 is flat — it is a property of the world, and no amount of data removes it. The parameter term ϕΣϕ\boldsymbol\phi^\top\boldsymbol\Sigma\boldsymbol\phi is 7.5%7.5\% of the total at x=0x = 0 and 95.3%95.3\% at x=5x = 5. Only the second one is reducible, which is the difference between aleatoric and epistemic uncertainty made arithmetic.

The middle panel is why maximum likelihood survives despite everything above. The posterior sd tracks 1/N1/\sqrt{N}, and the interval-width ratio falls from 1.2482131.248213 at N=5N = 5 to 1.0001131.000113 at N=10000N = 10000. At ten thousand points the two philosophies differ by one part in nine thousand. The expensive machinery earns its cost exactly where data is scarce — which is also exactly where page 803’s overfitting and page 805’s prior mattered most. The chapter keeps arriving at the same boundary.

The right panel is the term MAP dropped. logp(X)\log p(\mathcal{X}) climbs steeply from degree 0 to degree 3 and is then nearly flat, peaking at degree 6. Note the honest reading: degree 11 scores 30.2178-30.2178, only 0.25660.2566 nats behind the peak — a Bayes factor of 0.77370.7737, which is not evidence against anything. The marginal likelihood penalises unused capacity automatically, without a validation split and without a tuned λ\lambda, but it penalises it gently. Page 808 is where this becomes a selection rule.

maximum likelihoodMAPBayesian inference
section8.3.18.3.28.4.2
needs a priornoyesyes
needs p(X)p(\mathcal{X})nono, it cancelsyes, and it is an integral
computational problemoptimizationoptimizationintegration
answera pointa pointa distribution
predictionp(xθ)p(x \mid \boldsymbol\theta^*)p(xθ)p(x \mid \boldsymbol\theta^*)p(xθ)p(θ)dθ\int p(x \mid \boldsymbol\theta)p(\boldsymbol\theta)d\boldsymbol\theta
far-extrapolation coverage0.17960.17960.17960.17960.9498\mathbf{0.9498}
closed formoftenoftenonly with a conjugate prior
parameters θ\boldsymbol\thetalatent variables z\mathbf{z}
what they doparametrize the modeldescribe the generative process
usual treatmentestimatedmarginalised out
effect on parameter countthey are the countoften reduces it
in the likelihoodit is a function of themEq. 8.25: it must not depend on them
the book’s caveatthe separation is “somewhat arbitrary”
pch.quizTag Do you know what integration buys?
  1. Section 8.4.1 says a probabilistic model is specified by which object?

    pch.quizShowAnswer

    B — The joint distribution of all its random variables — Because only the joint has the property that all three of the others follow from it by a rule of probability: the prior and likelihood are its factors by the product rule, the marginal likelihood comes from integrating out the parameters by the sum rule, and the posterior is the joint divided by the marginal. That is why Section 8.5's graphical language describes the joint and nothing else.

  2. Measured over 4000 trials with the prior matched to the truth, what coverage does a nominal 95 percent plug-in interval achieve in far extrapolation?

    pch.quizShowAnswer

    B — 0.1796 — it covers the truth 18 percent of the time while claiming 95 — Its width is 1.3720 in every region, because two times 1.96 times sigma contains no reference to x. The full predictive achieves 0.9506, 0.9501 and 0.9498 across the three regions. This is what the book means by loss of information being critical in a system that uses predictions to make decisions.

  3. The predictive variance of Equation 8.23 is sigma squared plus phi-transpose Sigma phi. Which part shrinks as you collect more data?

    pch.quizShowAnswer

    B — Only the second — the noise floor is a property of the world — Measured on the chapter's data, the parameter term is 7.5 percent of the total at x = 0 and 95.3 percent at x = 5. Only that part is reducible. The noise floor of 0.1225 stays whatever you do, which is the difference between uncertainty about the world and uncertainty about your own parameters.

  4. The book says estimation and inference differ in their key computational problem. How?

    pch.quizShowAnswer

    B — Estimation solves an optimization problem; inference solves an integration problem — And that is why inference is the expensive one: finding a peak is cheap, summing over everything is not. Measured, the two converge as data accumulates — the interval-width ratio falls from 1.248213 at N = 5 to 1.000113 at N = 10000, which is why maximum likelihood is defensible on large data and reckless on small data.

  5. Equation 8.25 marginalises the latent variables out of the likelihood. What does the book insist about the result?

    pch.quizShowAnswer

    B — That the likelihood must NOT depend on z — only on the data x and the parameters theta — Measured on a two-component mixture, the marginal integrates to 1.00000000 in x and mentions z nowhere. That is the point of the two-step procedure: once the latents are integrated out, everything from Sections 8.3 and 8.4.2 applies unchanged, with no new machinery.

  6. Everything computed exactly on this page relies on which assumption?

    pch.quizShowAnswer

    B — That the prior is conjugate, so the integrals of Equations 8.22 and 8.23 have closed forms — The book is explicit: without a conjugate prior the integrals are not analytically tractable and you cannot compute the posterior, the predictions, or the marginal likelihood in closed form. Then you need approximations — MCMC, the Laplace approximation, variational inference, or expectation propagation.

Exercise 1 – Build the posterior, find the point estimate inside it

Section titled “Exercise 1 – Build the posterior, find the point estimate inside it”

Exercise 2 – Where the uncertainty comes from

Section titled “Exercise 2 – Where the uncertainty comes from”

Exercise 4 – The term MAP was allowed to drop

Section titled “Exercise 4 – The term MAP was allowed to drop”

Exercise 5 – Integrating out a latent variable

Section titled “Exercise 5 – Integrating out a latent variable”
  • Section 8.4.1’s definition: a probabilistic model IS the joint distribution of all its random variables. The prior and likelihood are its factors, the marginal likelihood is what you get by integrating out the parameters, and the posterior is the joint divided by the marginal. Only the joint has that property.
  • Equation 8.22 is Bayes’ theorem with the denominator kept. MAP could drop it because it is constant in theta; inference cannot, because it needs the posterior normalised. That integral is the source of every practical difficulty in this section.
  • Equation 8.23: the prediction is an average over all plausible parameters, weighted by how plausible each one is. The parameters are marginalised out, so the prediction no longer depends on them at all.
  • For a Gaussian model the predictive variance is the noise plus phi-transpose Sigma phi. The mean is identical to the plug-in prediction; only that second term differs, and it is exactly what the point estimate discarded.
  • Measured over 4000 trials with the prior matched to the truth: a nominal 95 percent full predictive achieves 0.9506, 0.9501 and 0.9498 across interpolation, mild and far extrapolation. The plug-in achieves 0.9287, 0.5701 and 0.1796.
  • The plug-in interval has width 1.3720 in every region, because two times 1.96 times sigma does not depend on where you ask. That constant is the entire failure.
  • Only the parameter term is reducible. It is 7.5 percent of the predictive variance at the centre of the data and 95.3 percent two units outside it. The noise floor never goes away.
  • The book’s comparison: estimation solves an OPTIMIZATION problem and returns a point; inference solves an INTEGRATION problem and returns a distribution. Predictions from a point are straightforward; predictions from a posterior need another integral.
  • They converge. The interval-width ratio falls from 1.248213 at N = 5 to 1.000113 at N = 10000. Maximum likelihood is defensible on large data and reckless on small data, which is the same boundary pages 803 and 805 kept arriving at.
  • The posterior mean equals the MAP estimate to 8.88e-16 for a Gaussian. MAP is incomplete, not wrong.
  • All of this is exact only because the prior is conjugate. Without conjugacy you lose the posterior, the predictions and the marginal likelihood in closed form simultaneously, and need MCMC, the Laplace approximation, variational inference or expectation propagation.
  • Bayesian inference cannot detect a wrong model class. On the chapter’s sine data fitted with a cubic, the full predictive still reaches only 0.8908 coverage. It quantifies doubt about theta inside the class you chose. Choosing the class is Section 8.6.
  • Section 8.4.3’s latent variables do not parametrize the model and usually mean fewer parameters, not more. Equation 8.25 integrates them out, and the resulting likelihood must be a function of the data and the parameters only.
  • Three posteriors, in order of difficulty: parameters given data, latents given data, both at once — the last is not possible in general. Equation 8.28, the latents given the data AND the parameters, is the tractable compromise, and it is what Chapters 10 and 11 actually compute.
  • The marginal likelihood penalises capacity automatically but gently. Measured: the peak is at degree 6, and degree 11 is only 0.2566 nats behind — a Bayes factor of 0.7737, which is no evidence at all.

Next: a picture of the joint distribution, and what you can read off it without doing any algebra. Directed Graphical Models

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading