Coder Social home page Coder Social logo

sayalirked / pymultinest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from johannesbuchner/pymultinest

1.0 0.0 0.0 1.83 MB

Pythonic Bayesian inference and visualization for the MultiNest Nested Sampling Algorithm and PyCuba's cubature algorithms.

Home Page: http://johannesbuchner.github.com/PyMultiNest/

License: Other

Python 100.00%

pymultinest's Introduction

PyMultiNest -- Python interface for MultiNest

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.org/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.com/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.com/PyMultiNest/index.html

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.

pymultinest's People

Contributors

aignas avatar astromancer avatar beckermr avatar jgukelberger avatar johannesbuchner avatar khyox avatar markdewing avatar smfactor avatar williamjameshandley avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.