anesthetic: nested sampling visualisation
Project description
- anesthetic:
nested sampling visualisation
- Version:
- 0.8.0
- Homepage:
- Documentation:
This project is still in beta phase. It aims to bring together tools for processing nested sampling chains, leveraging the standard python libraries:
numpy
scipy
matplotlib
pandas
As well as the state-of-the-art KDE tool:
fastKDE
You can see it in action in the plot gallery.
Current functionality includes:
Computation of Bayesian evidences, Kullback-Liebler divergences and Bayesian model dimensionalities.
Marginalised 1d and 2d plots.
Dynamic replaying of nested sampling run
This tool was designed primarily for use with nested sampling, although it can be used for normal MCMC chains.
For an interactive view of a nested sampling run, you can use the rhinestone script.
$ rhinestone <ns file root>
Installation
anesthetic can be installed via pip
pip install anesthetic
Or via the setup.py
git clone https://github.com/williamjameshandley/anesthetic
cd anesthetic
python setup.py install --user
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:
For large numbers of samples, kernel density estimation is slow, or inaccurate. There are now better state-of-the-art kernel density estimators, such as fastKDE, which ameliorate many of these difficulties.
Existing tools can make it painfully difficult to define new parameters. Take for example the default cosmomc chain, which defines omegabh2, but not omegab. The transformation is easy, since omegab = omegabh2/ (H0/100)**2, but writing this simple transformation in code 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.read(file_root) # Load the samples
h = samples['H0']/100 # Define h
samples['omegab'] = samples.omegabh2/h**2 # Define omegab
samples.tex['omegab'] = '$\Omega_b$' # Label omegab
samples.plot_1d('omegab') # Simple 1D plot
Many KDE plotting tools have conventions that don’t play well with uniformly distributed parameters, which is a pain 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.
Features
Both samples and plotting axes are stored as a pandas.DataFrame, which makes for easy access and modification
No overlapping tick labels in large plots
To Do
Fix nlive
better interfaces for plotting multiple samples
multiple nested sampler input formats (MultiNest, Dynesty, NeuralNest)
Read multiple MCMC chains
Legends
Implement live point reading for multinest
Histogram
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.