Nested sampling algorithm explained

The nested sampling algorithm is a computational approach to the Bayesian statistics problems of comparing models and generating samples from posterior distributions. It was developed in 2004 by physicist John Skilling.[1]

Background

Bayes' theorem can be applied to a pair of competing models

M1

and

M2

for data

D

, one of which may be true (though which one is unknown) but which both cannot be true simultaneously. The posterior probability for

M1

may be calculated as:

\begin{align} P(M1\midD)&=

P(D\midM1)P(M1)
P(D)

\\ &=

P(D\midM1)P(M1)
P(D\midM1)P(M1)+P(D\midM2)P(M2)

\\ &=

1
1+
P(D\midM2)
P(D\midM1)
P(M2)
P(M1)

\end{align}

The prior probabilities

M1

and

M2

are already known, as they are chosen by the researcher ahead of time. However, the remaining Bayes factor

P(D\midM2)/P(D\midM1)

is not so easy to evaluate, since in general it requires marginalizing nuisance parameters. Generally,

M1

has a set of parameters that can be grouped together and called

\theta

, and

M2

has its own vector of parameters that may be of different dimensionality, but is still termed

\theta

. The marginalization for

M1

is

P(D\midM1)=\intd\thetaP(D\mid\theta,M1)P(\theta\midM1)

and likewise for

M2

. This integral is often analytically intractable, and in these cases it is necessary to employ a numerical algorithm to find an approximation. The nested sampling algorithm was developed by John Skilling specifically to approximate these marginalization integrals, and it has the added benefit of generating samples from the posterior distribution

P(\theta\midD,M1)

.[2] It is an alternative to methods from the Bayesian literature[3] such as bridge sampling and defensive importance sampling.

Here is a simple version of the nested sampling algorithm, followed by a description of how it computes the marginal probability density

Z=P(D\midM)

where

M

is

M1

or

M2

:

Start with

N

points

\theta1,\ldots,\thetaN

sampled from prior. for

i=1

to

j

do % The number of iterations j is chosen by guesswork.

Li:=min(

current likelihood values of the points

)

;

Xi:=\exp(-i/N);

wi:=Xi-1-Xi

Z:=Z+Liwi;

Save the point with least likelihood as a sample point with weight

wi

. Update the point with least likelihood with some Markov chain Monte Carlo steps according to the prior, accepting only steps that keep the likelihood above

Li

. end return

Z

;

At each iteration,

Xi

is an estimate of the amount of prior mass covered by the hypervolume in parameter space of all points with likelihood greater than

\thetai

. The weight factor

wi

is an estimate of the amount of prior mass that lies between two nested hypersurfaces

\{\theta\midP(D\mid\theta,M)=P(D\mid\thetai-1,M)\}

and

\{\theta\midP(D\mid\theta,M)=P(D\mid\thetai,M)\}

. The update step

Z:=Z+Liwi

computes the sum over

i

of

Liwi

to numerically approximate the integral

\begin{align} P(D\midM)&=\intP(D\mid\theta,M)P(\theta\midM)d\theta\\ &=\intP(D\mid\theta,M)dP(\theta\midM) \end{align}

In the limit

j\toinfty

, this estimator has a positive bias of order

1/N

[4] which can be removed by using

(1-1/N)

instead of the

\exp(-1/N)

in the above algorithm.

The idea is to subdivide the range of

f(\theta)=P(D\mid\theta,M)

and estimate, for each interval

[f(\thetai-1),f(\thetai)]

, how likely it is a priori that a randomly chosen

\theta

would map to this interval. This can be thought of as a Bayesian's way to numerically implement Lebesgue integration.[5]

Implementations

Example implementations demonstrating the nested sampling algorithm are publicly available for download, written in several programming languages.

Applications

Since nested sampling was proposed in 2004, it has been used in many aspects of the field of astronomy. One paper suggested using nested sampling for cosmological model selection and object detection, as it "uniquely combines accuracy, general applicability and computational feasibility."[20] A refinement of the algorithm to handle multimodal posteriors has been suggested as a means to detect astronomical objects in extant datasets.[21] Other applications of nested sampling are in the field of finite element updating where the algorithm is used to choose an optimal finite element model, and this was applied to structural dynamics.[22] This sampling method has also been used in the field of materials modeling. It can be used to learn the partition function from statistical mechanics and derive thermodynamic properties. [23]

Dynamic nested sampling

Dynamic nested sampling is a generalisation of the nested sampling algorithm in which the number of samples taken in different regions of the parameter space is dynamically adjusted to maximise calculation accuracy.[24] This can lead to large improvements in accuracy and computational efficiency when compared to the original nested sampling algorithm, in which the allocation of samples cannot be changed and often many samples are taken in regions which have little effect on calculation accuracy.

Publicly available dynamic nested sampling software packages include:

Dynamic nested sampling has been applied to a variety of scientific problems, including analysis of gravitational waves,[29] mapping distances in space[30] and exoplanet detection.[31]

See also

Notes and References

  1. Skilling . John . Nested Sampling . AIP Conference Proceedings . 395–405 . 2004 . 735 . 10.1063/1.1835238. 2004AIPC..735..395S .
  2. Skilling . John . Nested Sampling for General Bayesian Computation . Bayesian Analysis . 1 . 4 . 833–860 . 2006 . 10.1214/06-BA127. free .
  3. Book: Chen, Ming-Hui, Shao, Qi-Man, and Ibrahim, Joseph George . Monte Carlo methods in Bayesian computation . Springer . 2000 . 978-0-387-98935-8 .
  4. Walter . Clement. Point-process based Monte Carlo estimation. Statistics and Computing. 219–236 . 2017. 27. 10.1007/s11222-015-9617-y . 1412.6368. 14639080.
  5. Jasa. Tomislav . Xiang . Ning. Nested sampling applied in Bayesian room-acoustics decay analysis . Journal of the Acoustical Society of America . 3251–3262 . 2012 . 132 . 5 . 10.1121/1.4754550. 23145609 . 2012ASAJ..132.3251J. 20876510 .
  6. http://www.inference.phy.cam.ac.uk/bayesys/ John Skilling website
  7. http://hackage.haskell.org/package/NestedSampling Nested sampling algorithm in Haskell at Hackage
  8. http://www.mrao.cam.ac.uk/~bn204/galevol/speca/rnested.html Nested sampling algorithm in R on Bojan Nikolic website
  9. https://github.com/bnikolic/RNested Nested sampling algorithm in R on GitHub
  10. Kester . D. . Mueller . M. . BayesicFitting, a PYTHON toolbox for Bayesian fitting and evidence calculation.: Including a Nested Sampling implementation. . Astronomy and Computing . 37 . 100503 . 2021 . 10.1016/j.ascom.2021.100503. free . 2109.11976 .
  11. https://github.com/dokester/BayesicFitting Python toolbox containing a Nested sampling algorithm on GitHub
  12. https://github.com/JorisDeRidder/DIAMONDS Nested sampling algorithm in C++ on GitHub
  13. https://github.com/js850/nested_sampling Nested sampling algorithm in Python on GitHub
  14. https://github.com/libAtoms/pymatnest Nested sampling algorithm for materials simulation on GitHub
  15. Feroz . F. . Hobson . M.P. . Multimodal nested sampling: an efficient and robust alternative to Markov Chain Monte Carlo methods for astronomical data analyses . MNRAS . 384 . 2 . 449–463 . 2008 . 10.1111/j.1365-2966.2007.12353.x . 2008MNRAS.384..449F . 0704.3704. 14226032 .
  16. https://github.com/farhanferoz/MultiNest The MultiNest nested sampling software package on GitHub
  17. https://github.com/PolyChord/PolyChordLite The PolyChord nested sampling software package on GitHub
  18. Handley . Will . Mike . Hobson . Anthony . Lasenby . polychord: next-generation nested sampling . Monthly Notices of the Royal Astronomical Society . 2015 . 453 . 4 . 4384–4398 . 10.1093/mnras/stv1911 . 2015MNRAS.453.4384H . 1506.00171 . 118882763 .
  19. https://github.com/TuringLang/NestedSamplers.jl Implementations of single and multi-ellipsoid nested sampling in Julia on GitHub
  20. Mukherjee . P. . Parkinson . D. . Liddle . A.R. . A Nested Sampling Algorithm for Cosmological Model Selection . Astrophysical Journal . 638 . 2 . 51–54 . 2006 . 2006ApJ...638L..51M . 10.1086/501068. astro-ph/0508461. 6208051 .
  21. Feroz . F. . Hobson . M.P. . Multimodal nested sampling: an efficient and robust alternative to Markov Chain Monte Carlo methods for astronomical data analyses . MNRAS . 384 . 2 . 449–463 . 2008 . 10.1111/j.1365-2966.2007.12353.x . 2008MNRAS.384..449F . 0704.3704. 14226032 .
  22. Mthembu . L. . Marwala . T. . Friswell . M.I. . Adhikari . S. . Model selection in finite element model updating using the Bayesian evidence statistic . Mechanical Systems and Signal Processing . 25 . 7 . 2399–2412 . 2011 . 10.1016/j.ymssp.2011.04.001. 2011MSSP...25.2399M .
  23. Partay. Livia B.. 2010. Efficient Sampling of Atomic Configurational Spaces. The Journal of Physical Chemistry B. 114. 32. 10502–10512. 10.1021/jp1012973. 20701382. 0906.3544. 16834142.
  24. Higson . Edward . Handley . Will . Hobson . Michael . Lasenby . Anthony . Dynamic nested sampling: an improved algorithm for parameter estimation and evidence calculation . Statistics and Computing . 2019 . 29 . 5 . 891–913 . 10.1007/s11222-018-9844-0 . 2019S&C....29..891H . 1704.03459 . 53514669 .
  25. https://github.com/joshspeagle/dynesty The dynesty nested sampling software package on GitHub
  26. Speagle . Joshua . dynesty: A Dynamic Nested Sampling Package for Estimating Bayesian Posteriors and Evidences . Monthly Notices of the Royal Astronomical Society . 2020 . 493 . 3 . 3132–3158 . 10.1093/mnras/staa278 . 1904.02180. 102354337 .
  27. Higson . Edward . dyPolyChord: dynamic nested sampling with PolyChord . Journal of Open Source Software . 2018 . 3 . 29 . 965 . 10.21105/joss.00965 . free .
  28. https://github.com/ejhigson/dyPolyChord The dyPolyChord dynamic nested sampling software package on GitHub
  29. Ashton . Gregory . Bilby: A User-friendly Bayesian Inference Library for Gravitational-wave Astronomy . The Astrophysical Journal Supplement Series . 2019 . 241 . 2 . 13 . 10.3847/1538-4365/ab06fc . etal. 2019ApJS..241...27A . 1811.02042 . 118677076 . free .
  30. Zucker . Catherine . Mapping Distances across the Perseus Molecular Cloud Using Observations, Stellar Photometry, and Gaia 2 Parallax Measurements . The Astrophysical Journal . 2018 . 869 . 1 . 83 . 10.3847/1538-4357/aae97c . etal. 1803.08931 . 119446622 . free .
  31. Günther . Maximilian . A super-Earth and two sub-Neptunes transiting the nearby and quiet M dwarf TOI-270 . Nature Astronomy . 2019 . 3 . 12 . 1099–1108 . 10.1038/s41550-019-0845-5 . etal. 2019NatAs...3.1099G . 1903.06107 . 119286334 .