In [ ]:
emcee3 is an MIT licensed Python toolbox for MCMC sampling. It is a backwards-incompatible extension of the popular emcee library to include more proposal distributions and other real world niceties. This documentation won't teach you too much about MCMC but there are a lot of resources available for that (try this one). We also published a paper explaining the core emcee algorithm and implementation in detail. emcee and emcee3 have been used in quite a few projects in the astrophysical literature and emcee3 is being actively developed on GitHub.
If you wanted to draw samples from a multidimensional Gaussian, you would do something like:
In [2]:
import emcee3
import numpy as np
# Define the probabilistic model:
def log_prior_function(x):
if np.all(-10. < x) and np.all(x < 10.):
return 0.0
return -np.inf
def log_likelihood_function(x):
return -0.5 * np.sum(x ** 2)
model = emcee3.SimpleModel(log_likelihood_function, log_prior_function)
# Initialize:
ndim, nwalkers = 10, 100
ensemble = emcee3.Ensemble(model, np.random.randn(nwalkers, ndim))
# Sample:
sampler = emcee3.Sampler()
ensemble = sampler.run(ensemble, 1000)
A more complete example is available in the quickstart documentation.
In [ ]: