Skip to main content

nested sampling post-processing

Project description

Authors:

Will Handley and Lukas Hergt

Version:
2.8.15
Homepage:

https://github.com/handley-lab/anesthetic

Documentation:

http://anesthetic.readthedocs.io/

Build Status Test Coverage Status Documentation Status PyPi location Conda location Permanent DOI for this release Review Status License information

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

TLDR: See the quickstart.

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>
https://github.com/handley-lab/anesthetic/raw/master/images/anim_1.gif

Features

  • 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.

Installation

anesthetic can be installed via pip

pip install anesthetic

via conda

conda install -c handley-lab anesthetic

or from the github repository

git clone https://github.com/handley-lab/anesthetic
cd anesthetic
python -m pip install .

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

export MPLBACKEND=Agg     # only necessary for OSX users
python -m pip install ".[test]"
python -m pytest
flake8 anesthetic tests
pydocstyle --convention=numpy anesthetic

Dependencies

Basic requirements:

Documentation:

Tests:

Documentation

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:

python -m pip install ".[all,docs]"
cd docs
make html

and view the documentation by opening docs/build/html/index.html in a browser. To regenerate the automatic RST files run:

sphinx-apidoc -fM -t docs/templates/ -o docs/source/ anesthetic/

Citation

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, https://doi.org/10.21105/joss.01414

or using the BibTeX:

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

Contributing

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.

Questions/Comments

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 read_chains
samples = read_chains(file_root)               # Load the samples
label = 'omegab'
tex = '$\Omega_b$'
h = (samples.H0/100)
samples[(label, tex)] = samples.omegabh2/h**2  # Define 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 a 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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anesthetic-2.8.15.tar.gz (100.3 kB view details)

Uploaded Source

Built Distribution

anesthetic-2.8.15-py3-none-any.whl (76.1 kB view details)

Uploaded Python 3

File details

Details for the file anesthetic-2.8.15.tar.gz.

File metadata

  • Download URL: anesthetic-2.8.15.tar.gz
  • Upload date:
  • Size: 100.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for anesthetic-2.8.15.tar.gz
Algorithm Hash digest
SHA256 42c6c4792c6ec32ec8862aebab51f1a64deffb4c044c27e8e8850cbfdf3d1765
MD5 6d0536d0481d1738f0740fb371727e1e
BLAKE2b-256 78b199ff6691828ab4762d8ddcd53aebd10ee3c8e6adf7955ea2272470d0ed6a

See more details on using hashes here.

File details

Details for the file anesthetic-2.8.15-py3-none-any.whl.

File metadata

  • Download URL: anesthetic-2.8.15-py3-none-any.whl
  • Upload date:
  • Size: 76.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for anesthetic-2.8.15-py3-none-any.whl
Algorithm Hash digest
SHA256 61ffed546611134750ea6099fa07bacbb83d9939fbe783c766ddf54388c0abe8
MD5 789501d82f74e44dc55e88db44945bc1
BLAKE2b-256 529040c43256b862a9eefba27b33723145c9bac14dd1219583dc4232a9b8d9b2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page