Skip to content
Nested Sampling post-processing
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Updated docstrings of gui Apr 16, 2019
.github Updated docstrings of gui Apr 16, 2019
anesthetic Updated bug in nsamples May 22, 2019
docs Reverted to old numpydoc Apr 22, 2019
paper Added makefile for creating tex May 12, 2019
scripts Corrected anesthetic script Apr 22, 2019
tests added beta as a property Apr 21, 2019
.gitignore Updated the demo Apr 19, 2019
.readthedocs.yml Still trying to fix RTD Mar 31, 2019
.travis.yml Removed python 3.4 support for now Apr 19, 2019
LICENSE Create LICENSE Mar 28, 2019
README.rst typo fix in README May 22, 2019
demo.ipynb Updated the Apr 22, 2019 Updated the Apr 22, 2019
environment.yml Updated demo Apr 19, 2019 Fixed multinest reading Apr 21, 2019
requirements.txt Still trying to fix RTD Mar 31, 2019
run_tests Added run tests unix script Apr 18, 2019 Updated Apr 19, 2019 Experiments with edge effects Mar 20, 2019


anesthetic: nested sampling visualisation

anesthetic:nested sampling visualisation
Author: Will Handley
Version: 1.0.2
Build Status Test Coverage Status Documentation Status PyPi location Permanent DOI for this release Review Status License information Online interactive notebook

anesthetic brings together tools for processing nested sampling chains, leveraging standard scientific python libraries.

You can see example usage and plots in the plot gallery, or in the corresponding Jupyter notebook.

Current functionality includes:

  • Computation of Bayesian evidences, Kullback-Liebler divergences and Bayesian model dimensionalities.
  • Marginalised 1d and 2d plots.
  • Dynamic replaying of nested sampling.

This tool was designed primarily for use with nested sampling outputs, although it can be used for normal MCMC chains.

For an interactive view of a nested sampling run, you can use the anesthetic script.

$ anesthetic <ns file root>


  • Both samples and plotting axes are stored as a pandas.DataFrame, with parameter names as indices, which makes for easy access and modification.
  • Sensible color scheme for plotting nearly flat distributions.
  • For easy extension/modification, uses the standard python libraries: numpy, scipy, matplotlib and pandas.


anesthetic can be installed via pip

pip install anesthetic

or via the

git clone
cd anesthetic
python install --user

You can check that things are working by running the test suite:

export MPLBACKEND=Agg     # only necessary for OSX users
python -m pytest
flake8 anesthetic tests
pydocstyle --convention=numpy anesthetic


Basic requirements:




Full Documentation is hosted at ReadTheDocs. To build your own local copy of the documentation you'll need to install sphinx. You can then run:

cd docs
make html


If you use anesthetic to generate plots for a publication, please cite as:

Handley, (2019). anesthetic: nested sampling visualisation. Journal of Open
Source Software, 4(37), 1414,

or using the BibTeX:

    doi = {10.21105/joss.01414},
    url = {},
    year  = {2019},
    month = {Jun},
    publisher = {The Open Journal},
    volume = {4},
    number = {37},
    author = {Will Handley},
    title = {anesthetic: nested sampling visualisation},
    journal = {The Journal of Open Source Software}


There are many ways you can contribute via the GitHub repository.

  • You can open an issue to report bugs or to propose new features.
  • Pull requests are very welcome. Note that if you are going to propose major changes, be sure to open an issue for discussion first, to make sure that your PR will be accepted before you spend effort coding it.


Another posterior plotting tool?

This is my posterior plotter. There are many like it, but this one is mine.

There are several excellent tools for plotting marginalised posteriors:

Why create another one? In general, any dedicated user of software will find that there is some functionality that in their use case is lacking, and the designs of previous codes make such extensions challenging. In my case this was:

  1. For large numbers of samples, kernel density estimation is slow, or inaccurate (particularly for samples generated from nested sampling). There are kernel density estimators, such as fastKDE, which ameliorate many of these difficulties.
  2. Existing tools can make it difficult to define new parameters. For example, the default cosmomc chain defines omegabh2, but not omegab. The transformation is easy, since omegab = omegabh2/ (H0/100)**2, but implementing this transformation in existing packages is not so trivial. anesthetic solves this issue by storing the samples as a pandas array, for which the relevant code for defining the above new parameter would be
from anesthetic import MCMCSamples
samples = MCMCSamples(root=file_root)                         # Load the samples
samples['omegab'] = samples.omegabh2/(samples.H0/100)**2      # Define omegab
samples.tex['omegab'] = '$\Omega_b$'                          # Label omegab
samples.plot_1d('omegab')                                     # Simple 1D plot
  1. Many KDE plotting tools have conventions that don't play well with uniformly distributed parameters, which presents a problem if you are trying to plot priors along with your posteriors. anesthetic has a sensible mechanism, by defining the contours by the amount of iso-probability mass they contain, but colouring the fill in relation to the probability density of the contour.

What's in a name?

There is an emerging convention for naming nested sampling packages with words that have nest in them (nestle and dynesty, nestorflow). Doing a UNIX grep:

grep nest /usr/share/dict/words

yields a lot of superlatives (e.g. greenest), but a few other cool names for future projects:

  • amnesty
  • defenestrate
  • dishonestly
  • inestimable
  • minestrone
  • rhinestone

I chose anesthetic because I liked the soft 'th', and in spite of the US spelling.


1.0.0:End of beta testing
You can’t perform that action at this time.