Skip to content

Instantly share code, notes, and snippets.

@dfm
Created November 29, 2012 22:52

Revisions

  1. dfm created this gist Nov 29, 2012.
    13 changes: 13 additions & 0 deletions jsick.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    import numpy as np
    import emcee


    def lnprob(x, ivar):
    return -0.5 * np.array([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])
    sampler.run_mcmc(p0, 1000)