Skip to content

Instantly share code, notes, and snippets.

@dfm
Last active December 17, 2015 16:29
Show Gist options
  • Select an option

  • Save dfm/5639401 to your computer and use it in GitHub Desktop.

Select an option

Save dfm/5639401 to your computer and use it in GitHub Desktop.
emcee progress

Here's what happens if you want to display the progress of the default emcee example from the main documentation page.

import numpy as np
import emcee
def lnprob(x, ivar):
return -0.5 * np.sum(ivar * x ** 2)
ndim, nwalkers = 10, 100
ivar = 1. / np.random.rand(ndim)
p0 = [np.random.rand(ndim) for i in range(nwalkers)]
sampler = emcee.EnsembleSampler(nwalkers, ndim, lnprob, args=[ivar])
niterations = 1000
for i, (pos, lnprob, state) in enumerate(sampler.sample(p0, iterations=niterations)):
print("I've done {0:.0f} percent of the steps".format(int(100 * i / niterations)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment