This is an old version, view current version.
24.2 Computing the posterior predictive distribution
The posterior predictive density (or mass) of a prediction ˜y given observed data y can be computed using Monte Carlo draws
θ(m)∼p(θ∣y) from the posterior as p(˜y∣y)≈1MM∑m=1p(˜y∣θ(m)).
Computing directly using this formula will lead to underflow in many situations, but the log posterior predictive density, logp(˜y∣y) may be computed using the stable log sum of exponents function as logp(˜y∣y)≈log1MM∑m=1p(˜y∣θ(m)).=−logM+log-sum-expMm=1logp(˜y∣θ(m)), where log-sum-expMm=1vm=logM∑m=1expvm is used to maintain arithmetic precision. See the section on log sum of exponentials for more details.