Skip to main content

Come analyze HEASARC, IRSA, and MAST data in the cloud! The Fornax Initiative is now welcoming all interested beta users.

Xspec Home Page

Nested sampling (nest)

Nested sampling, introduced by Skilling (2004), is fundamentally different from the three MCMC samplers above. Rather than drawing from the posterior directly, it maintains a set of $K$ “live points” distributed according to the prior and iteratively replaces the lowest-likelihood live point with a new draw from the prior, conditioned on having a higher likelihood than the one removed. As the algorithm proceeds the live points climb up the likelihood surface and converge on the posterior modes. The posterior samples are recovered as a weighted re-sampling of the removed (“dead”) points; the evidence

$\displaystyle Z = \int p(D\vert\bm{\theta})\,p(\bm{\theta})\,d\bm{\theta}$ (3.3)

falls out for free as a side product.

Strengths.    Nested sampling is the natural choice when the goal includes model comparison via Bayes factors. It explores multi-modal posteriors much more reliably than any MCMC method because the live points span the entire prior at the start. It does not require a starting fit; running fit before nest run has no effect on the sampler at all. The XSPEC implementation supports multi-process parallelization via parallel nest, which uses the K-point-removal generalization of Buchner (2014) to remove $K$ live points per iteration and parallelize the $K$ resamplings.

Weaknesses.    The per-iteration cost is one or more constrained prior samples, which can themselves require many likelihood evaluations. Nested sampling is slower than HMC on smooth unimodal posteriors but much more reliable on hard ones. The number of iterations scales as roughly $H \cdot K \cdot D$ where $H$ is the information gained in going from the prior to the posterior — the Kullback–Leibler divergence between the two distributions, measured in nats (the unit of information based on the natural logarithm, as the bit is based on log base 2; roughly, $H$ counts how many $e$-foldings the posterior volume is compressed relative to the prior volume). For typical X-ray problems this is a few thousand iterations and $K = 400$ live points is reasonable.

The strongest constraint nested sampling places on the user is that the prior must be properly normalized on a bounded domain. Parameters with default flat priors over many decades will cause nest run to refuse to start; the user must apply jeffreys (with the parameter's hard lower limit pushed above zero by newpar) or another integrable prior before invoking nest.

Tips.    Set nest live $400$ as a default; lower values risk under-exploring multi-modal regions, higher values cost proportionally more. Use parallel nest $N$ where $N$ is roughly the number of physical cores; the speedup is sub-linear but significant. Allow an elapsed-time budget of order an hour for $\sim$6 parameter problems on a single CCD; multi-instrument joint fits with response convolution dominate by an order of magnitude.