Foundations to Frontier
Tests
A. Mathematical Foundations › A5 Statistics › Bayesian statistics

Posterior Predictive Distributions

What will the next observation be? The posterior predictive averages the data model over everything the posterior still allows, p(y_new | data) = ∫ p(y_new | θ) p(θ | data) dθ, so predictions carry two kinds of uncertainty: irreducible noise (aleatoric) and what the data haven't pinned down yet (epistemic). You will compute beta-binomial, negative-binomial and Gaussian predictives, see why plug-in predictions are overconfident (especially when extrapolating), and use posterior predictive checks to find out whether a model can reproduce the data at all.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Two reasons a prediction can miss

You’ve timed a robot’s grasp 8 times. How long will the next grasp take? Two things make the answer uncertain:

  1. Noise: even a perfectly understood robot varies a little from grasp to grasp.
  2. What you don’t know yet: with only 8 tests, you haven’t pinned down the robot’s true average.

A good prediction includes both. Ignoring the second makes predictions overconfident, especially for situations unlike the ones you tested.

Predicting the next measurement: noise + what we don't know yet
predictive sd at x = 0: 0.332 · at x = 2.2 (extrapolating): 8.941 · plug-in sd (noise only): 0.300
Data are drawn only between the grey lines (x ∈ [−1, 1]). Orange: the posterior predictive mean of a cubic Bayesian regression. Blue band: ±2 predictive sd = √(σ² + parameter variance). Purple: functions sampled from the posterior. Grey dashed: the plug-in band that uses only the noise σ. It's far too confident outside the data, where the posterior samples disagree wildly.
Why engineers care

A robot planning a path needs to know how uncertain its model is in unexplored regions. A reliability engineer needs the chance of failures in the next 100 missions, not just the estimated failure rate. And before trusting a model at all, you should check that data it simulates look like the real data.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Prediction uncertainty comes from noise and…
  2. 2. Far from the tested conditions, uncertainty about the model…
  3. 3. Using only the best-fit parameters to predict makes you…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Definition

p(y~∣x)=∫p(y~∣θ) p(θ∣x) dθp(\tilde y\mid x) = \int p(\tilde y\mid\theta)\,p(\theta\mid x)\,d\theta

Simulation recipe: draw θ(s)∼p(θ∣x)\theta^{(s)}\sim p(\theta\mid x), then y~(s)∼p(y~∣θ(s))\tilde y^{(s)}\sim p(\tilde y\mid\theta^{(s)}). The y~(s)\tilde y^{(s)} are predictive draws.

Closed forms

  • Beta–binomial: posterior Beta(a, b), next mm trials. P(j)=(mj)B(a+j,b+m−j)B(a,b)P(j) = \binom mj\frac{B(a + j, b + m - j)}{B(a, b)}. With m=1m = 1, this is just the posterior mean.
  • Gamma–Poisson: posterior Gamma(α, rate β) on a rate. The next window’s count is negative binomial, with mean α/β\alpha/\beta and variance αβ⋅β+1β\frac\alpha\beta\cdot\frac{\beta + 1}\beta. That’s overdispersed relative to Poisson.
  • Normal mean, known σ: posterior N(mn,tn2)\mathcal N(m_n, t_n^2). Predictive N(mn,σ2+tn2)\mathcal N(m_n, \sigma^2 + t_n^2). With a flat prior, σ2(1+1/n)\sigma^2(1 + 1/n).

Plug-in vs predictive

Plug-in prediction uses p(y~∣θ^)p(\tilde y\mid\hat\theta). It ignores the tn2t_n^2 term, so its intervals are too narrow, its tails too thin, and its rare-event probabilities too small. After 7 of 10 successes, the plug-in says P(0 of the next 5) = 0.004. The predictive says 0.013, three times larger.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Predictive variance for a normal mean with known σ is…
  2. 2. The Gamma–Poisson predictive is a…
  3. 3. To simulate from the predictive, first…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Bayesian linear regression

With prior w∼N(0,τ2I)w\sim\mathcal N(0, \tau^2I) and noise σ2\sigma^2, the posterior is N(m,S)\mathcal N(m, S), with S=(X⊤X/σ2+I/τ2)−1S = (X^\top X/\sigma^2 + I/\tau^2)^{-1} and m=SX⊤y/σ2m = SX^\top y/\sigma^2. The predictive at a new input x∗x_* is

y~∣x∗∼N(x∗⊤m, σ2⏟aleatoric+x∗⊤Sx∗⏟epistemic)\tilde y\mid x_*\sim\mathcal N\big(x_*^\top m,\ \underbrace{\sigma^2}_{\text{aleatoric}} + \underbrace{x_*^\top Sx_*}_{\text{epistemic}}\big)

The epistemic part shrinks where you have data and grows when extrapolating. GPs (A4.4-6) behave the same way.

Posterior predictive checks

Does the model reproduce the data’s important features? Choose a test statistic TT, such as the max residual, the kurtosis, the number of zeros, or the autocorrelation. Compare T(y)T(y) with T(yrep)T(y^{\text{rep}}), where yrepy^{\text{rep}} is drawn from the posterior predictive. The posterior predictive p-value is P(T(yrep)≥T(y)∣y)P(T(y^{\text{rep}})\ge T(y)\mid y). Values near 0 or 1 flag misfit (Gelman, Meng and Stern, 1996). Pick statistics that probe the assumption you doubt. A check on the mean can’t detect wrong tails.

🐍 Exercise 1: predictive distributions and their honesty
Compute beta-binomial predictive probabilities (and check them by two-stage simulation), compare predictive vs plug-in interval coverage for a normal mean, and show that the Bayesian linear-regression predictive variance grows when extrapolating.
📝 Quick check (Level 2)
0/3 answered
  1. 1. In BLR the epistemic variance at x* is…
  2. 2. A posterior predictive p-value of 0.001 for max|residual| suggests…
  3. 3. Which statistic would NOT reveal heavy tails?

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Deriving the normal predictive

If μ∣x∼N(mn,tn2)\mu\mid x\sim\mathcal N(m_n, t_n^2) and y~=μ+ε\tilde y = \mu + \varepsilon with independent ε∼N(0,σ2)\varepsilon\sim\mathcal N(0, \sigma^2), then y~∣x\tilde y\mid x is a sum of independent normals: N(mn,tn2+σ2)\mathcal N(m_n, t_n^2 + \sigma^2). ∎ By the law of total variance (A4.1-8), in general:

Var⁡(y~∣x)=E[Var⁡(y~∣θ)∣x]⏟aleatoric+Var⁡(E[y~∣θ]∣x)⏟epistemic\operatorname{Var}(\tilde y\mid x) = \underbrace{\mathbb E[\operatorname{Var}(\tilde y\mid\theta)\mid x]}_{\text{aleatoric}} + \underbrace{\operatorname{Var}(\mathbb E[\tilde y\mid\theta]\mid x)}_{\text{epistemic}}

Deep ensembles and MC dropout estimate exactly this split for neural networks (Kendall and Gal, 2017).

Deriving the negative binomial predictive

P(k)=∫λke−λk!βαλα−1e−βλΓ(α)dλ=Γ(α+k)Γ(α)k!(ββ+1)α(1β+1)kP(k) = \int\frac{\lambda^ke^{-\lambda}}{k!}\frac{\beta^\alpha\lambda^{\alpha-1}e^{-\beta\lambda}}{\Gamma(\alpha)}d\lambda = \frac{\Gamma(\alpha + k)}{\Gamma(\alpha)k!}\Big(\frac\beta{\beta + 1}\Big)^\alpha\Big(\frac1{\beta + 1}\Big)^k, by recognising a Gamma integral. ∎

Why predictive intervals are calibrated (and plug-in ones aren’t)

If the model and prior are correct, (θ,x,y~)(\theta, x, \tilde y) follow the joint distribution, and predictive intervals have exact average coverage (A5.2-1). Plug-in intervals condition on θ^\hat\theta as if it were the truth. Their coverage is below nominal by an amount of order 1/n1/n, and much worse when extrapolating.

Exercise 3.1: Show that the m = 1 beta-binomial predictive is the posterior mean

P(success)=∫p Beta(p;a,b) dp=aa+bP(\text{success}) = \int p\,\text{Beta}(p; a, b)\,dp = \frac a{a + b}.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The aleatoric/epistemic split of predictive variance comes from…
  2. 2. Plug-in intervals under-cover because they ignore…
  3. 3. Gamma–Poisson predictive variance exceeds its mean by the factor…

Level 4: Expert

★★★★★ Expert⏱ 40 minResearchers: original papers and open problems.

Checking a range-sensor noise model

A filter designer models lidar range residuals as Gaussian. A posterior predictive check with the statistic max |z| tells whether a Gaussian model could plausibly produce the most extreme residual actually observed. For clean residuals, the check passes (ppp ≈ 0.5). With 5% multipath outliers it fails decisively (ppp ≈ 0). A check on the mean would have passed both. The fix is a heavier-tailed or mixture likelihood (A4.2-6), or explicit outlier gating, before trusting the filter’s covariance.

🐍 Exercise 2 (research): posterior predictive check of a Gaussian noise model
Fit a normal model (reference prior) to range residuals, draw replicated datasets from the posterior predictive, and compute posterior predictive p-values for max|z|. Show that clean residuals pass, multipath-contaminated residuals fail, and that a check on the mean misses the problem.

Predictive distributions in AI, robotics and aerospace

  • Model-based RL and planning with uncertainty-aware models: PILCO propagates GP predictive uncertainty (Deisenroth and Rasmussen, 2011), and PETS uses probabilistic ensembles to avoid exploiting model errors (Chua et al., 2018).
  • Aleatoric vs epistemic uncertainty in perception. Separating the two tells a robot whether to collect more data (epistemic) or accept the noise (aleatoric) (Kendall and Gal, 2017).
  • Reliability forecasting. Predictive distributions of failures in the next fleet-hours, not plug-in Poisson counts, set spares and maintenance (Hamada et al., 2008).
  • Model validation. Posterior predictive and simulation-based checks are part of the Bayesian workflow before any decision (Gelman et al., 2020).
  • Probabilistic forecasting of weather and space weather is scored by proper scoring rules (log score, CRPS) of the predictive distribution (Gneiting and Raftery, 2007).

References

  1. A. Gelman, X.-L. Meng, H. Stern (1996). “Posterior predictive assessment of model fitness via realized discrepancies.” Statistica Sinica, 6.
  2. A. Gelman et al. (2020). “Bayesian workflow.” arXiv:2011.01808.
  3. C. Bishop (2006). Pattern Recognition and Machine Learning, Sec. 3.3. Springer.
  4. A. Kendall, Y. Gal (2017). “What uncertainties do we need in Bayesian deep learning for computer vision?” NeurIPS.
  5. M. Deisenroth, C. Rasmussen (2011). “PILCO: a model-based and data-efficient approach to policy search.” ICML.
  6. K. Chua, R. Calandra, R. McAllister, S. Levine (2018). “Deep reinforcement learning in a handful of trials using probabilistic dynamics models.” NeurIPS.
  7. T. Gneiting, A. Raftery (2007). “Strictly proper scoring rules, prediction, and estimation.” JASA, 102(477).
  8. M. Hamada, A. Wilson, C. S. Reese, H. Martz (2008). Bayesian Reliability. Springer.
  9. B. Lakshminarayanan, A. Pritzel, C. Blundell (2017). “Simple and scalable predictive uncertainty estimation using deep ensembles.” NeurIPS.
  10. A. Gelman, J. Carlin, H. Stern, D. Dunson, A. Vehtari, D. Rubin (2013). Bayesian Data Analysis, 3rd ed., Ch. 6. CRC Press.