Skip to main content

Access modules for the MultiNest and Cuba integration libraries

Project description

This library provides programmatic access to MultiNest and PyCuba.

What is MultiNest?

MultiNest is a program and a sampling technique. As a Bayesian inference technique, it allows parameter estimation and model selection. (find out more in the MultiNest paper, http://arxiv.org/abs/0809.3437, or in a classic MCMC sampler, http://apemost.sf.net/ ). Recently, MultiNest added Importance Nested Sampling (INS, see http://arxiv.org/abs/1306.2144) which is now also supported.

The efficient Monte Carlo algorithm for sampling the parameter space is based on nested sampling and the idea of disjoint multi-dimensional ellipse sampling.

For the scientific community, where Python is becoming the new lingua franca (luckily), I provide an interface to MultiNest.

https://travis-ci.com/JohannesBuchner/PyMultiNest.svg?branch=master

The automatic build makes sure both Python 2.7 and Python 3 are working correctly with MultiNest and Cuba. It also tests that MultiNest works with MPI enabled.

What does PyMultiNest do?

PyMultiNest

  • provides an easy-to-use interface to MultiNest and Cuba integration algorithms

  • allows connecting with your existing scientific Python code (numpy, scipy)

  • allows Prior & LogLikelihood functions written in Python.

  • Easy plotting, visualization and summary of MultiNest results.

  • Running MultiNest with MPI

The plotting can also be run on existing MultiNest output, and when not using PyMultiNest for running MultiNest.

Citing PyMultiNest

See http://johannesbuchner.github.io/PyMultiNest/index.html#citing-pymultinest

Plotting results, corner and trace plots

If you got pymultinest running with your likelihood (based on the pymultinest_demo*.py examples), you can create plots of the marginal probability distributions.

If you set outputfiles_basename=”myprefix-” in the run, you need to create a file myprefix-params.json which gives the names of each parameters, for example:

[
  "param1",
  "param2",
  "$N\_\mathrm{H}$",
  "norm",
]

Then you can run:

$ python pymultinest-folder/multinest_marginals.py myprefix-

which will create marginal plots for you.

Recently I also added support for corner.py (needs to be installed):

$ python pymultinest-folder/multinest_marginals_corner.py myprefix-

Also possible is trace and corner plots:

$ python pymultinest-folder/multinest_marginals_fancy.py myprefix-

This last one has some potential drawbacks however: The code I borrowed here from dynesty is not meant for multi-modal nested sampling which reorders the points, so the trace plot may not be 100% correct for multi-modal problems.

Questions and Problems

For any questions or problems with the software, please open an issue. This helps other people google the same question.

Using MultiNest with Python?

Look at the documentation available at http://johannesbuchner.github.io/PyMultiNest/

What is PyCuba?

Cuba (http://www.feynarts.de/cuba/, https://github.com/JohannesBuchner/cuba) is a multidimensional numerical integration library for low dimensions. PyCuba allows integration of Python functions, providing an advanced alternative to the basic functions provided in scipy.integrate.

In the Bayesian sense, it is possible to use Cuba for model selection.

Q: Python callback functions are too slow!

If you really identified that your callback functions are too slow, even when using the usual tricks (numpy, etc.), you can implement and compile them as C functions.

You still have the neat python interface (default parameters, etc.), but achieve full execution speed, as only native code is executed while MultiNest runs.

Project details


Download files

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

Source Distribution

pymultinest-2.12.tar.gz (883.3 kB view details)

Uploaded Source

Built Distributions

pymultinest-2.12-py3.10.egg (62.8 kB view details)

Uploaded Source

pymultinest-2.12-py2.py3-none-any.whl (50.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pymultinest-2.12.tar.gz.

File metadata

  • Download URL: pymultinest-2.12.tar.gz
  • Upload date:
  • Size: 883.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for pymultinest-2.12.tar.gz
Algorithm Hash digest
SHA256 a8ac6787fa0dd9b374a3a2e981d48a1975e935ac846a8083d209078443d3e90c
MD5 94de61d6e615d2e36b835ff99211c11d
BLAKE2b-256 55f299a108aca74a6c1d9390d328a2e94b57e76695d7b365a89b7b5027a0b710

See more details on using hashes here.

File details

Details for the file pymultinest-2.12-py3.10.egg.

File metadata

  • Download URL: pymultinest-2.12-py3.10.egg
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for pymultinest-2.12-py3.10.egg
Algorithm Hash digest
SHA256 325d63fa0c60211e2eaa82c863c30196752f959e5777dfb848822dde01909904
MD5 bdad8269e6e169a17c489efbd876f9e9
BLAKE2b-256 fcbded03c4a2fd37eacdb1cbb8c327132fdfc115e0c0eb672421d3306ac38f58

See more details on using hashes here.

File details

Details for the file pymultinest-2.12-py2.py3-none-any.whl.

File metadata

  • Download URL: pymultinest-2.12-py2.py3-none-any.whl
  • Upload date:
  • Size: 50.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for pymultinest-2.12-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c643d789364169f3a98c2f1966fdbe2eabff923747d42dc44eac7f8206052722
MD5 23d6d2efddf9e453fbe4938f5da68bcf
BLAKE2b-256 6925a603aa4cf4d7653e8ff492da93302920fecdd3bb3e3b1b05bb1a1176f721

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