MCMC-Bridge

philastrophist/mcmc-bridge

PyMC3 is a platform in which to specify your Bayesian hierarchical model. It is a probabilistic language but also contains it’s own samplers.

emcee is a ubiquitous, perhaps the go-to sampler for astronomers. It is probably the first sampler you’ll come across in the literature because it is very powerful. emcee is an affine-invariant sampler, so it can deal with complex multi-dimensional likelihoods. PyMC3 just doesn’t have a comparable sampler in its arsenal and integrating them is actually not straightforward.

Here’s where MCMC-Bridge comes in.

You can simply write your model as before but then export to the emcee sampler to run it! We can then easily turn the emcee trace back into the flexible PyMC3 trace object and continue on our way. Emcee can utilise MPI and multi-processing and so MCMC-Bridge allows the easy use of cluster resources by adding a pool or threads option to export_to_emcee.