/NestedSampling.hs

Classic Nested Sampling in Haskell.

Primary LanguageHaskellMIT LicenseMIT

NestedSampling.hs

MIT License

(c) 2016 Brendon J. Brewer and Jared Tobin

This is a Haskell implementation of the classic Nested Sampling algorithm introduced by John Skilling. You can use it for Bayesian inference, statistical mechanics, and optimisation applications.

There are a few examples included that you can run using Stack as follows:

$ stack test NestedSampling-hs:test:spikeslab
$ stack test NestedSampling-hs:test:rosenbrock

.. and so on. Check the .cabal file for a list of examples, the code for which can always be found in the test directory.

Running any of these examples will log sampling progress to stdout and also dump output information to a couple of CSV files:

  • nested_sampling_info.csv includes log x, log prior weight, log likelihood, current log evidence estimate, and current information estimate by sampler iteration.
  • nested_sampling_parameters.csv includes parameter information (where one line = one sample).

You can then run a Python postprocessing script to generate some plots, and a text file of posterior weights:

$ python showresults.py

This script requires NumPy, Matplotlib, and Pandas.