Nested sampling algorithm

From Wikipedia, the free encyclopedia

Template:Short description Lua error in package.lua at line 80: module 'Module:Sidebar/configuration' not found. 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 used for model selection, where one has 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. Bayesian model selection provides a method for assessing the Bayes factor, which gives the relative merit of each model.

The posterior probability for M1 may be calculated as:

P(M1D)=P(DM1)P(M1)P(D)=P(DM1)P(M1)P(DM1)P(M1)+P(DM2)P(M2)=11+P(DM2)P(DM1)P(M2)P(M1)

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(DM2)/P(DM1) 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 θ, and M2 has its own vector of parameters that may be of different dimensionality, but is still termed θ. The marginalization for M1 is

P(DM1)=dθP(Dθ,M1)P(θM1)

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(θD,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(DM) where M is M1 or M2:

Start with N points θ1,,θN 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:=Xi1Xi
    Z:=Z+Liwi;
    Save the point with least likelihood as a sample point with weight wi.
    Update the point with least likelihood by sampling from the prior restricted to likelihoods above Li, for example with Markov chain Monte Carlo.
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 θi. The weight factor wi is an estimate of the amount of prior mass that lies between two nested hypersurfaces {θP(Dθ,M)=P(Dθi1,M)} and {θP(Dθ,M)=P(Dθi,M)}. The update step Z:=Z+Liwi computes the sum over i of Liwi to numerically approximate the integral

P(DM)=P(Dθ,M)P(θM)dθ=P(Dθ,M)dP(θM)

In the limit j, this estimator has a positive bias of order 1/N[4] which can be removed by using (11/N) instead of the exp(1/N) in the above algorithm.

The idea is to subdivide the range of f(θ)=P(Dθ,M) and estimate, for each interval [f(θi1),f(θi)], how likely it is a priori that a randomly chosen θ would map to this interval. This can be thought of as a Bayesian's way to numerically implement Lebesgue integration.[5][6]

Likelihood-restricted prior sampling algorithms

The point with least likelihood can be updated with some Markov chain Monte Carlo steps according to the prior, accepting only steps that keep the likelihood above Li. The original procedure outlined by Skilling (given above in pseudocode) does not specify what specific algorithm should be used to choose new points with better likelihood, but several algorithms have been developed.[7]

Skilling's own code examples (such as one in Sivia and Skilling (2006),[8] available on Skilling's website) chooses a random existing point and selects a nearby point chosen by a random distance from the existing point; if the likelihood is better, then the point is accepted, else it is rejected and the process repeated. Subsequently, a variety of MCMC algorithms tailored for nested sampling have been developed, including slice sampling,[5] popularized by PolyChord, and constrained Hamiltonian Monte Carlo.[9]

An alternative line of algorithms is based on rejection sampling. Mukherjee et al. (2006)[10] found higher acceptance rates by selecting points randomly within an ellipsoid drawn around the existing points; this idea was refined by the MultiNest algorithm[11] which handles multimodal posteriors better using multiple ellipsoids built from clustering of the live points. Rejection methods can be efficient up to 20-30 dimensions.[7]

Implementations

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

  • Simple examples in C, R, or Python are on John Skilling's website.
  • A Haskell port of the above simple codes is on Hackage.
  • An example in R originally designed for fitting spectra is described on Bojan Nikolic's website and is available on GitHub.
  • A NestedSampler is part of the Python toolbox BayesicFitting[12] for generic model fitting and evidence calculation. It is available on GitHub.
  • An implementation in C++, named DIAMONDS, is on GitHub.
  • A highly modular Python parallel example for statistical physics and condensed matter physics uses is on GitHub.
  • pymatnest is a package designed for exploring the energy landscape of different materials, calculating thermodynamic variables at arbitrary temperatures and locating phase transitions is on GitHub
  • The MultiNest software package is capable of performing nested sampling on multi-modal posterior distributions.[11][13] It has interfaces for C++, Fortran and Python inputs, and is available on GitHub.
  • PolyChord is another nested sampling software package available on GitHub. PolyChord's computational efficiency scales better with an increase in the number of parameters than MultiNest, meaning PolyChord can be more efficient for high dimensional problems.[14] It has interfaces to likelihood functions written in Python, Fortran, C, or C++. PolyChord can be used jointly with Cobaya,[15] a Python-based code for Bayesian analysis of hierarchical physical models. Cobaya facilitates exploration of posteriors using various Monte Carlo samplers, allows for maximization and importance-reweighting of samples, and includes interfaces to cosmological theory codes and likelihoods.
  • NestedSamplers.jl, a Julia package for implementing single- and multi-ellipsoidal nested sampling algorithms is on GitHub.
  • Korali is a high-performance framework for uncertainty quantification, optimization, and deep reinforcement learning, which also implements nested sampling.
  • The UltraNest software package implements a fast MPI-capable, generalized multi-ellipsoidal dynamic nested sampling algorithm. The user can also choose slice sampling algorithms. Written in Python, it has interfaces for Python, C, Fortran, Python, R and Julia and is available on GitHub.

Applications

Since nested sampling was proposed in 2004, it has been used in many science areas,[6] in particular in astronomy. One paper suggested using nested sampling for cosmological model selection and object detection, as it "uniquely combines accuracy, general applicability and computational feasibility."[10] A refinement of the algorithm to handle multimodal posteriors has been suggested as a means to detect astronomical objects in extant datasets.[13] 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.[16] 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.[17]

Diagnostics

Dedicated diagnostics for nested sampling have been developed for verifying that a nested sampling run is performing well. This includes a U test that the rank of the likelihood of the replacement point is uniformly distributed among the live points,[18][7] Markov Chain Monte Carlo jump distance,[19] comparison of the consistency of several independent nested sampling runs,[20][21] including reruns with increased number of MCMC steps. The computation can also be checked with generically applicable techniques such as simulation-based calibration.[22]

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.[23] This can lead to 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:

  • dynesty – a Python implementation of dynamic nested sampling which can be downloaded from GitHub.[24]
  • dyPolyChord: a software package which can be used with Python, C++ and Fortran likelihood and prior distributions.[25] dyPolyChord is available on GitHub.
  • UltraNest (see above).

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

See also

References

Page Template:Reflist/styles.css has no content.

  1. ^ Page Module:Citation/CS1/styles.css has no content.Skilling, John (2004). "Nested Sampling". AIP Conference Proceedings. 735: 395–405. Bibcode:2004AIPC..735..395S. doi:10.1063/1.1835238.
  2. ^ Page Module:Citation/CS1/styles.css has no content.Skilling, John (2006). "Nested Sampling for General Bayesian Computation". Bayesian Analysis. 1 (4): 833–860. doi:10.1214/06-BA127.
  3. ^ Page Module:Citation/CS1/styles.css has no content.Chen, Ming-Hui, Shao, Qi-Man, and Ibrahim, Joseph George (2000). Monte Carlo methods in Bayesian computation. Springer. ISBN 978-0-387-98935-8.{{cite book}}: CS1 maint: multiple names: authors list (link)
  4. ^ Page Module:Citation/CS1/styles.css has no content.Walter, Clement (2017). "Point-process based Monte Carlo estimation". Statistics and Computing. 27: 219–236. arXiv:1412.6368. doi:10.1007/s11222-015-9617-y. S2CID 14639080.
  5. ^ a b Page Module:Citation/CS1/styles.css has no content.Jasa, Tomislav; Xiang, Ning (2012). "Nested sampling applied in Bayesian room-acoustics decay analysis". Journal of the Acoustical Society of America. 132 (5): 3251–3262. Bibcode:2012ASAJ..132.3251J. doi:10.1121/1.4754550. PMID 23145609. S2CID 20876510.
  6. ^ a b Page Module:Citation/CS1/styles.css has no content.Ashton, Greg; Bernstein, Noam; Buchner, Johannes; Chen, Xi; Csányi, Gábor; Fowlie, Andrew; Feroz, Farhan; Griffiths, Matthew; Handley, Will; Habeck, Michael; Higson, Edward; Hobson, Michael; Lasenby, Anthony; Parkinson, David; Pártay, Livia B.; Pitkin, Matthew; Schneider, Doris; Speagle, Joshua S.; South, Leah; Veitch, John; Wacker, Philipp; Wales, David J.; Yallup, David (26 May 2022). "Nested sampling for physical scientists". Nature Reviews Methods Primers. 2 (1) 39. arXiv:2205.15570. Bibcode:2022NRvMP...2...39A. doi:10.1038/s43586-022-00121-x.
  7. ^ a b c Page Module:Citation/CS1/styles.css has no content.Buchner, Johannes (1 January 2023). "Nested sampling methods". Statistics Surveys. 17: 169. arXiv:2101.09675. Bibcode:2023StSur..17..169B. doi:10.1214/23-SS144.
  8. ^ Page Module:Citation/CS1/styles.css has no content.Sivia, Devinderjit; Skilling, John (June 2006). Data Analysis: A Bayesian Tutorial. Oxford: Oxford University Press, USA. ISBN 978-0-19-856832-2.
  9. ^ Page Module:Citation/CS1/styles.css has no content.Betancourt, Michael (2011). "Nested Sampling with Constrained Hamiltonian Monte Carlo". AIP Conf. Proc. AIP Conference Proceedings. 1305 (1): 165–172. arXiv:1005.0157. Bibcode:2011AIPC.1305..165B. doi:10.1063/1.3573613.
  10. ^ a b Page Module:Citation/CS1/styles.css has no content.Mukherjee, P.; Parkinson, D.; Liddle, A.R. (2006). "A Nested Sampling Algorithm for Cosmological Model Selection". Astrophysical Journal. 638 (2): 51–54. arXiv:astro-ph/0508461. Bibcode:2006ApJ...638L..51M. doi:10.1086/501068. S2CID 6208051.
  11. ^ a b Page Module:Citation/CS1/styles.css has no content.Feroz, F.; Hobson, M.P.; Bridges, M. (2008). "MULTINEST: an efficient and robust Bayesian inference tool for cosmology and particle physics". MNRAS. 398 (4): 1601–1614. arXiv:0809.3437. doi:10.1111/j.1365-2966.2009.14548.x.
  12. ^ Page Module:Citation/CS1/styles.css has no content.Kester, D.; Mueller, M. (2021). "BayesicFitting, a PYTHON toolbox for Bayesian fitting and evidence calculation.: Including a Nested Sampling implementation". Astronomy and Computing. 37 100503. arXiv:2109.11976. Bibcode:2021A&C....3700503K. doi:10.1016/j.ascom.2021.100503.
  13. ^ a b Page Module:Citation/CS1/styles.css has no content.Feroz, F.; Hobson, M.P. (2008). "Multimodal nested sampling: an efficient and robust alternative to Markov Chain Monte Carlo methods for astronomical data analyses". MNRAS. 384 (2): 449–463. arXiv:0704.3704. Bibcode:2008MNRAS.384..449F. doi:10.1111/j.1365-2966.2007.12353.x. S2CID 14226032.
  14. ^ Page Module:Citation/CS1/styles.css has no content.Handley, Will; Hobson, Mike; Lasenby, Anthony (2015). "polychord: next-generation nested sampling". Monthly Notices of the Royal Astronomical Society. 453 (4): 4384–4398. arXiv:1506.00171. Bibcode:2015MNRAS.453.4384H. doi:10.1093/mnras/stv1911. S2CID 118882763.
  15. ^ Page Module:Citation/CS1/styles.css has no content.Torrado, Jesús; Lewis, Antony (2021-05-01). "Cobaya: code for Bayesian analysis of hierarchical physical models". Journal of Cosmology and Astroparticle Physics. 2021 (5): 057. arXiv:2005.05290. Bibcode:2021JCAP...05..057T. doi:10.1088/1475-7516/2021/05/057. ISSN 1475-7516.
  16. ^ Page Module:Citation/CS1/styles.css has no content.Mthembu, L.; Marwala, T.; Friswell, M.I.; Adhikari, S. (2011). "Model selection in finite element model updating using the Bayesian evidence statistic". Mechanical Systems and Signal Processing. 25 (7): 2399–2412. Bibcode:2011MSSP...25.2399M. doi:10.1016/j.ymssp.2011.04.001.
  17. ^ Page Module:Citation/CS1/styles.css has no content.Partay, Livia B. (2010). "Efficient Sampling of Atomic Configurational Spaces". The Journal of Physical Chemistry B. 114 (32): 10502–10512. arXiv:0906.3544. Bibcode:2010JPCB..11410502P. doi:10.1021/jp1012973. PMID 20701382. S2CID 16834142.
  18. ^ Page Module:Citation/CS1/styles.css has no content.Fowlie, Andrew; Handley, Will; Su, Liangliang (1 October 2020). "Nested sampling cross-checks using order statistics". Monthly Notices of the Royal Astronomical Society. 497 (4): 5256–5263. arXiv:2006.03371. doi:10.1093/mnras/staa2345.
  19. ^ Page Module:Citation/CS1/styles.css has no content.Buchner, Johannes (February 2024). "Relative Jump Distance: A diagnostic for Nested Sampling". arXiv:2402.11936 [stat.ME].
  20. ^ Page Module:Citation/CS1/styles.css has no content.Higson, Edward; Handley, Will; Hobson, Mike; Lasenby, Anthony (1 September 2018). "Sampling Errors in Nested Sampling Parameter Estimation". Bayesian Analysis. 13 (3): 873. arXiv:1703.09701. Bibcode:2018BayAn..13..873H. doi:10.1214/17-BA1075.
  21. ^ Page Module:Citation/CS1/styles.css has no content.Higson, Edward; Handley, Will; Hobson, Michael; Lasenby, Anthony (21 February 2019). "nestcheck : diagnostic tests for nested sampling calculations". Monthly Notices of the Royal Astronomical Society. 483 (2): 2044–2056. arXiv:1804.06406. doi:10.1093/mnras/sty3090.
  22. ^ Page Module:Citation/CS1/styles.css has no content.Talts, Sean; Betancourt, Michael; Simpson, Daniel; Vehtari, Aki; Gelman, Andrew (April 2018). "Validating Bayesian Inference Algorithms with Simulation-Based Calibration". arXiv:1804.06788 [stat.ME].
  23. ^ Page Module:Citation/CS1/styles.css has no content.Higson, Edward; Handley, Will; Hobson, Michael; Lasenby, Anthony (2019). "Dynamic nested sampling: an improved algorithm for parameter estimation and evidence calculation". Statistics and Computing. 29 (5): 891–913. arXiv:1704.03459. Bibcode:2019S&C....29..891H. doi:10.1007/s11222-018-9844-0. S2CID 53514669.
  24. ^ Page Module:Citation/CS1/styles.css has no content.Speagle, Joshua (2020). "dynesty: A Dynamic Nested Sampling Package for Estimating Bayesian Posteriors and Evidences". Monthly Notices of the Royal Astronomical Society. 493 (3): 3132–3158. arXiv:1904.02180. doi:10.1093/mnras/staa278. S2CID 102354337.
  25. ^ Page Module:Citation/CS1/styles.css has no content.Higson, Edward (2018). "dyPolyChord: dynamic nested sampling with PolyChord". Journal of Open Source Software. 3 (29): 965. doi:10.21105/joss.00965.
  26. ^ Page Module:Citation/CS1/styles.css has no content.Ashton, Gregory; et al. (2019). "Bilby: A User-friendly Bayesian Inference Library for Gravitational-wave Astronomy". The Astrophysical Journal Supplement Series. 241 (2): 13. arXiv:1811.02042. Bibcode:2019ApJS..241...27A. doi:10.3847/1538-4365/ab06fc. S2CID 118677076.
  27. ^ Page Module:Citation/CS1/styles.css has no content.Zucker, Catherine; et al. (2018). "Mapping Distances across the Perseus Molecular Cloud Using {CO} Observations, Stellar Photometry, and Gaia {DR}2 Parallax Measurements". The Astrophysical Journal. 869 (1): 83. arXiv:1803.08931. doi:10.3847/1538-4357/aae97c. S2CID 119446622.
  28. ^ Page Module:Citation/CS1/styles.css has no content.Günther, Maximilian; et al. (2019). "A super-Earth and two sub-Neptunes transiting the nearby and quiet M dwarf TOI-270". Nature Astronomy. 3 (12): 1099–1108. arXiv:1903.06107. Bibcode:2019NatAs...3.1099G. doi:10.1038/s41550-019-0845-5. S2CID 119286334.