Reference, not teaching. Each entry names the book’s number, states the result,
and gives the condition it needs. Read the concept pages first; come back here
when you are working.
an instance of the law of total variance,
V[x]=EY[V[x∣y]]+VY[E[x∣y]].
§6.5.4 sampling. If x∼N(0,I) then
y=Ax+μ has covariance
AA⊤. Choose A as the Cholesky factor: it
exists because covariances are symmetric positive definite, and it is triangular.
Theorem 6.15 (probability integral transform). For continuous X with a
strictly monotonic cdf, Y:=FX(X) is uniform. Run backwards, that is
inverse-transform sampling.
np.var(x) (two-pass internally), never mean(x**2) - mean(x)**2
unbiased variance
np.var(x, ddof=1)
covariance matrix
np.cov(X.T, bias=True) for the book’s 1/N
correlation
np.corrcoef(x, y)
Gaussian conditioning
mu_x + Sxy @ np.linalg.solve(Syy, y - mu_y)
sample a Gaussian
z @ np.linalg.cholesky(S).T + mu
log-density, stably
np.linalg.slogdet plus np.linalg.solve, never inv
Beta functions
math.lgamma, and work in logs
inverse-transform sample
F_inverse(rng.random(n))
pch.quizTagCheck your understanding
Which of the chapter's results is the computational bottleneck in probabilistic modelling?
The book flags it in a Remark. Bayes and the product rule are free; the evidence in Equation 6.27 is a high-dimensional integral, which is why variational inference and MCMC exist at all.
pch.quizShowAnswer
B — The sum rule, Equation 6.20 — marginalising D binary variables costs 2^D terms, which is 1.27e30 at D = 100, with no known exact polynomial-time algorithm — The book flags it in a Remark. Bayes and the product rule are free; the evidence in Equation 6.27 is a high-dimensional integral, which is why variational inference and MCMC exist at all.
What single property makes the Gaussian the workhorse of the chapter?
That is why Exercise 6.5 produces the Kalman filter with no new mathematics, and why Exercise 6.12 produces Bayesian linear regression the same way.
pch.quizShowAnswer
B — Closure: marginalising, conditioning, multiplying, adding and affine mapping all return Gaussians, each by a closed-form formula in the mean and covariance — so inference is matrix algebra rather than integration — That is why Exercise 6.5 produces the Kalman filter with no new mathematics, and why Exercise 6.12 produces Bayesian linear regression the same way.
Why is conjugacy more than a convenience?
And it works because multiplying exponential-family densities adds natural parameters. Pitman, Darmois and Koopman proved those are the only families with finite-dimensional sufficient statistics.
pch.quizShowAnswer
B — It satisfies the second desideratum: the parameter count does not grow with the data. Measured at two numbers after 100000 observations, against 200^D for a grid — 1e23 at D = 10 — And it works because multiplying exponential-family densities adds natural parameters. Pitman, Darmois and Koopman proved those are the only families with finite-dimensional sufficient statistics.
You reparameterise a model from sigma to log-sigma and your MAP estimate changes. Bug or not?
Only affine reparameterisations leave the mode alone, since their Jacobian is constant. If a point estimate must survive a change of coordinates, report a posterior quantile rather than a MAP.
pch.quizShowAnswer
B — Not a bug. A density's mode is not reparameterisation-invariant, because the Jacobian reweights it — measured, the mode of exp(X) is 0.3679 rather than exp(0) = 1. Quantiles, including the median, ARE invariant — Only affine reparameterisations leave the mode alone, since their Jacobian is constant. If a point estimate must survive a change of coordinates, report a posterior quantile rather than a MAP.
Two datasets give identical Gaussian log-likelihoods to 2.3e-13 but look completely different. What follows?
This is the flip side of conjugacy's convenience: a fixed parameter count can absorb unbounded data precisely because the data compresses to a fixed-size summary first. Skew and multimodality are simply not in that summary.
pch.quizShowAnswer
B — They share the sufficient statistics — n, the sum and the sum of squares — so by Theorem 6.14 no inference about mu or sigma can distinguish them. Everything downstream of the likelihood inherits that blindness — This is the flip side of conjugacy's convenience: a fixed parameter count can absorb unbounded data precisely because the data compresses to a fixed-size summary first. Skew and multimodality are simply not in that summary.
Two rules generate the chapter. The sum rule (Eq 6.20) collapses an axis; the product rule (Eq 6.22) factorises a cell. Bayes (Eq 6.23) is those two rearranged.
The sum rule is the expensive one: 2^D terms for D binary variables, 1.27e30 at D = 100, with no known exact polynomial-time algorithm.
A random variable is a FUNCTION, and Eq 6.8 defines its law through the pre-image because that function can collapse outcomes.
A density is not a probability. Def 6.1 bounds the integral, not the height — measured 1.4286, 39.89 and 1e8 with the integral exactly 1 each time. And P(X=x) = 0 exactly for continuous X.
The cdf is the only one of the three that is always a probability, and some cdfs have no pdf.
Eq 6.13 normalises columns, Eq 6.14 rows. Assert the axis sums; a transposed conditional is invisible otherwise.
The likelihood is not a distribution in x. It needs the prior and the evidence to become one.
The evidence (Eq 6.27) is the likelihood averaged under the PRIOR, and it is the hard integral.
A zero prior is permanent — exactly 0.0000000000 after 400 confirming observations, silently.
The base-rate fallacy, measured: P(disease | +) = 0.0902 at prevalence 0.001 with a 99% test, an overstatement of 10.98x.
Expectation is linear (Eq 6.34) with no independence needed; covariance (Eq 6.36) measures only LINEAR dependence, so zero covariance does not imply independence.
Eq 6.44 is numerically unsafe: returns 0 for a variance of 4 once the data is offset by 1e9. Use Eq 6.43.
The book’s empirical covariance is BIASED (1/N) and it says so; at N = 2 that is half the true variance.
Eq 6.51’s V[Ax+b] = A Sigma A-transpose takes the OUTPUT’s shape and can be singular, hence have no density.
The Gaussian is closed under everything — marginalise (6.68), condition (6.66, 6.67), multiply (6.74–6.77), add (6.78), map affinely (6.88) — each in closed form.
Conditioning can only shrink the covariance, and not at all if the cross-covariance is zero.
Precisions ADD when Gaussians multiply, so a Gaussian posterior is always sharper than its prior.
A mixture of Gaussians is NOT Gaussian (Thm 6.12), and its variance has a between-component term that was 90% of the answer in the worked case.
Sample a Gaussian with the Cholesky factor: triangular, and guaranteed to exist for a covariance matrix.
Eq 6.107’s exponential family has sufficiency built in — the data reaches the parameters only through phi(x) — and dA/dtheta = E[phi(x)].
The Bernoulli’s natural parameter is the log-odds, and its inverse is the SIGMOID (Eq 6.118).
Conjugacy is structural: multiplying exponential-family densities adds natural parameters, so Eq 6.120 generates a conjugate prior for every member.
Transforming a continuous variable needs a Jacobian (Eq 6.143, Thm 6.16); dropping it is a shape error no renormalisation repairs.
Theorem 6.15: F_X(X) is uniform for any continuous X with a strictly monotonic cdf — moments are irrelevant. Backwards, it is inverse-transform sampling.
A mode is not reparameterisation-invariant; a quantile is.