Coder Social home page Coder Social logo

emcee3's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

emcee3's Issues

Shape of `chain` and `lnprobabilty` attributes are not consistent

Using emcee2 I get the following shapes after sampling:

sampler.chain: (30, 100, 3)
sampler.lnprobability: (30, 100)

Using the latest version 3.0rc2 the shapes are:

sampler.chain: (30, 100, 3)
sampler.lnprobability: (100, 30)

So the shape of chain stayed the same, but new current shape of lnprobability is not consistent anymore.

Problem (?) with "backends" feature

Hello to all,

I am running emcee 3.0rc2 with the "backends" feature and when i try to access the .h5 file i get the following error:

Traceback (most recent call last):
File "testing.py", line 23, in
samples = reader.get_chain(discard=burnin, flat=True)
File "/usr/local/lib/python3.6/dist-packages/emcee/backends/backend.py", line 72, in get_chain
return self.get_value("chain", **kwargs)
File "/usr/local/lib/python3.6/dist-packages/emcee/backends/hdf.py", line 101, in get_value
raise AttributeError("You must run the sampler with "
AttributeError: You must run the sampler with 'store == True' before accessing the results

The testing.py file contains the following:

reader = emcee.backends.HDFBackend('test_ff.h5')
fname = 'test_clust_1'
burnin = 1
samples = reader.get_chain(discard=burnin, flat=True)
bs = 40
labels = ['a','b','c','$\sigma_{e}$','k']
ax = corner.corner(samples,plot_contours = True, fill_contours = True,plot_datapoints = False, \ show_titles = True, bins = bs, levels = [0.,0.6827,0.9545,0.9973],labels=labels,title_fmt=".4f")
ax.savefig(fname+'.pdf')

The call of the run_emcee is done as follows:
if extra_force == "multithreading":
with multiprocessing.Pool() as pool:
sampler = emcee.EnsembleSampler(nwalkers, ndim, lnlikelihood, \ pool=pool,backend=backends)
start = tm.time()
sampler.run_mcmc(initial, states, progress=prog_bar)
end = tm.time()
multi_time = end - start
# print("Multiprocessing took {0:.1f} seconds".format(multi_time))

Is there anyone with the same problem? Perhaps I oversee something trivial.
Anyway, thanks for your time

Need to update examples

import numpy as np
import emcee3


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)]


model = emcee3.SimpleModel(lnprob, args=(ivar,))
# sampler = emcee3.Sampler(moves=emcee3.moves.StretchMove())
sampler = emcee3.Sampler(moves=emcee3.moves.KDEMove())
ensemble = emcee3.Ensemble(model, p0)

sampler.run(ensemble, 1000, progress=True)

chains = sampler.get_coords()
s = chains.shape
flatchain = chains.reshape(s[0] * s[1], s[2])

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.