  Bayesian highest posterior density (HPD) intervals can be estimated directly
from simulations via empirical shortest intervals. Unfortunately, these can be
noisy (that is, have a high Monte Carlo error). We derive an optimal weighting
strategy using bootstrap and quadratic programming to obtain a more compu-
tationally stable HPD, or in general, shortest probability interval (Spin). We
prove the consistency of our method. Simulation studies on a range of theoret-
ical and real-data examples, some with symmetric and some with asymmetric
posterior densities, show that intervals constructed using Spin have better
cov- erage (relative to the posterior distribution) and lower Monte Carlo error
than empirical shortest intervals. We implement the new method in an R package
(SPIn) so it can be routinely used in post-processing of Bayesian simulations.
