Skip to main content

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.

Release files for pymultinest 2.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymultinest 2.12
File Size Uploaded
pymultinest-2.12.tar.gz 883.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pymultinest 2.12
File Interpreter ABI Platform
pymultinest-2.12-py3.10.egg Legacy Egg format - - Details
pymultinest-2.12-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 996.9 kB

Release files / pymultinest-2.12.tar.gz

Download URL pymultinest-2.12.tar.gz
Size 883.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a8ac6787fa0dd9b374a3a2e981d48a1975e935ac846a8083d209078443d3e90c
BLAKE2b-256 checksum
How to use checksums
55f299a108aca74a6c1d9390d328a2e94b57e76695d7b365a89b7b5027a0b710
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / pymultinest-2.12-py3.10.egg

Download URL pymultinest-2.12-py3.10.egg
Size 62.8 kB
Tags Egg
SHA-256 checksum
How to use checksums
325d63fa0c60211e2eaa82c863c30196752f959e5777dfb848822dde01909904
BLAKE2b-256 checksum
How to use checksums
fcbded03c4a2fd37eacdb1cbb8c327132fdfc115e0c0eb672421d3306ac38f58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / pymultinest-2.12-py2.py3-none-any.whl

Download URL pymultinest-2.12-py2.py3-none-any.whl
Size 50.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c643d789364169f3a98c2f1966fdbe2eabff923747d42dc44eac7f8206052722
BLAKE2b-256 checksum
How to use checksums
6925a603aa4cf4d7653e8ff492da93302920fecdd3bb3e3b1b05bb1a1176f721
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

2.12 This release

3 release files

2.11

3 release files

2.10

3 release files

2.9

3 release files

2.7

3 release files

2.6

3 release files

2.5

3 release files

2.2

3 release files

2.1

2 release files

1.9

2 release files

1.8

2 release files

1.6

2 release files

1.5

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

0.4

2 release files

0.3

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page