anesthetic: nested sampling visualisation

anesthetic is a Python package for processing nested sampling runs, and will be useful for any scientist or statistician who uses nested sampling software. anesthetic unifies many existing tools and techniques in an extensible framework that is intuitive for users familiar with the standard Python packages, namely NumPy, SciPy, Matplotlib and pandas.


Summary
anesthetic is a Python package for processing nested sampling runs, and will be useful for any scientist or statistician who uses nested sampling software. anesthetic unifies many existing tools and techniques in an extensible framework that is intuitive for users familiar with the standard Python packages, namely NumPy, SciPy, Matplotlib and pandas. It has been extensively used in recent cosmological papers (W. Handley andLemos 2019a, 2019b).

Nested sampling
Nested sampling (Skilling 2006) is an alternative to Markov-Chain-Monte-Carlo techniques (Hastings 1970). Given some data D, for a scientific model M with free parameters θ, Bayes theorem states: Traditional MCMC approaches ignore the Bayesian evidence P (D) and instead focus on the problem of generating samples from the posterior P (θ|D) using knowledge of the prior P (θ) and likelihood P (D|θ). Nested sampling reverses this priority, and instead computes the evidence P (D) (the critical quantity in Bayesian model comparison (Trotta 2008)), producing posterior samples as a by-product. Nested sampling does this by evolving a set of live points drawn from the prior under a hard likelihood constraint which steadily increases, causing the live points to contract around the peak(s) of the likelihood. The history of the live-point evolution can be used to reconstruct both the evidence and posterior samples, as well as the density of states and consequently the full partition function.
Current publicly available implementations of nested sampling include MultiNest (Feroz, Hobson, and Bridges 2009) A subset of computations from item 1 is provided by many of the nested sampling software packages. anesthetic allows you to compute these independently and more accurately, providing a unified set of outputs and separating these computations from the generation of nested samples.
Item 2 is useful for users that have experienced the phenomenon of 'live point watching'the process of continually examining the evolution of the live points as the run progresses in an attempt to diagnose problems in likelihood and/or sampling implementations. The GUI provided allows users to fully reconstruct the run at any iteration, and examine the effect of dynamically adjusting the thermodynamic temperature.
Finally, it is important to recognise that the functionality from item 3 is also provided by many other high-quality software packages, such as getdist (Lewis 2015), corner (Foreman-Mackey 2016), pygtc (Bocquet and Carter 2016), dynesty (Speagle 2019) and MontePython (Brinckmann and Lesgourgues 2019). anesthetic adds to this functionality by: • Performing kernel density estimation using the state-of-the-art fastkde (O'Brien et al. 2016) algorithm. • Storing samples and plotting grids as a weighted pandas.DataFrame, which is more consistent with the scientific Python canon, allows for unambiguous access to samples and plots via their reference names, and easy definition of new parameters. • Using a contour colour scheme that is better suited to plotting distributions with uniform probability, which is important if one wishes to plot priors along with posteriors.
The source code for anesthetic is available on GitHub, with its automatically generated documentation at ReadTheDocs and a pip-installable package on PyPi. An example interactive Jupyter notebook is given using Binder (Jupyter et al. 2018). Continuous integration is implemented with Travis and Circle.