Posterior predictive inference turns uncertainty about model parameters into uncertainty about an unknown outcome. Instead of producing one prediction, it produces a distribution of plausible outcomes by combining the posterior distribution with the data-generating process and observation noise. section 3.15 section 3.18
For Bayesian linear regression, each test value receives a predictive mean and variance. The mean describes the expected label, while the spread reflects both uncertainty in the slope and randomness in new observations. A 95% credible interval summarizes a useful range of predictions. section 3.15 section 3.18
A practical posterior predictive workflow is:
- Draw parameter values from the posterior. section 4.7
- Generate new outcomes from each sampled parameter value, using fresh observation noise rather than reusing training noise. section 4.7
- Compare the simulated outcomes with observed data using intervals, distributions, or standardized residuals. section 4.7
- Treat close agreement as evidence that the model can realistically reproduce the observations, not as proof that the model is correct. section 4.7
House-price prediction
For each house size, compute a predictive normal distribution for price. Plot its mean as a line and its 95% credible interval as a band. If most observed prices fall inside the intervals, the predictions represent the observed variation reasonably well. section 3.15 section 4.7
Tea-preference check
For five surveyed people, simulate the number preferring tea from posterior predictive samples. An ArviZ posterior predictive plot compares the observed count of three with the simulated range and average distribution. section 5.13
xs = np.linspace(500, 2500, 101) #A
y_mean = xs * post_mu #B
y_var = (
xs**2 * post_sigma2
+ sigma2_noise
) #C
Use the compact NumPy calculation to inspect predictive means and variances across a grid of test values. section 3.15
with model:
ppc = pm.sample_posterior_predictive(
samples, var_names=["k"]
)
az.plot_ppc(ppc)
Use PyMC to sample posterior predictions and ArviZ to visualize their comparison with observed data. section 5.13
