Nested sampling (Skilling, 2006) is a popular numerical method for Bayesian computation, which simultaneously generates samples from the posterior distribution and an estimate of the Bayesian evidence for a given likelihood and prior. Dynamic nested sampling (Higson et al., 2019a) is a generalisation of the nested sampling algorithm which can provide order-of-magnitude increases in computational efficiency.

perfectns performs dynamic nested sampling and standard nested sampling for spherically symmetric likelihoods and priors, and analyses the samples produced. The spherical symmetry allows the nested sampling algorithm to be followed “perfectly” - i.e. without additional errors due to correlations between samples, which are present in other nested sampling software.

The specialised methods used by perfectns make it highly effective and reliable for spherically symmetric calculations. The software is also intended for use in research into the statistical properties of nested sampling, and to provide a benchmark for testing the performance of nested sampling software packages used for practical problems - which rely on numerical techniques to produce approximately uncorrelated samples. For details of the theory behind the software and of how it performs perfect nested sampling, see the see the theory section of the documentation.

To get started, see the installation instructions and the demo. For more examples of perfectns’s use, see the code used to make the results and figures in the dynamic nested sampling paper (


If perfectns is useful for your academic research, please cite the two papers introducing the software and the dynamic nested sampling algorithm. The BibTeX is:

author = {Higson, Edward},
title = {perfectns: perfect dynamic and standard nested sampling for spherically symmetric likelihoods and priors},
doi = {10.21105/joss.00985},
journal = {Journal of Open Source Software},
number = {30},
pages = {985},
volume = {3},
year = {2018}}

author={Higson, Edward and Handley, Will and Hobson, Michael and Lasenby, Anthony},
title={Dynamic nested sampling: an improved algorithm for parameter estimation and evidence calculation},
journal={Statistics and Computing},


The changelog for each release can be found at


Contributions are welcome! Development takes place on github:

When creating a pull request, please try to make sure the tests pass and use numpy-style docstrings.

If you have any questions or suggestions please get in touch (

Authors & License

Copyright 2018-Present Edward Higson and contributors (MIT license).