ValueError: algorithm must be 'MT19937' when creating sampler
See original GitHub issueGeneral information:
- emcee version: v3.0rc2
- platform: Ubuntu 18.04.1 LTS
- installation method (pip/conda/source/other?): pip install emcee==3.0rc2
Problem description:
Running emcee.EnsembleSampler() throws error.
Expected behavior:
No error, creating the sampler correctly.
Actual behavior:
ValueError: algorithm must be 'MT19937'
What have you tried so far?:
The error is coming from emcee/ensemble.py, line 133. I tried printing state variable, and it seems like the first element of this list, which should be 'MT19937' is in reality b'MT19937'. So it seems like it is a bytes string. As a quick fix I tried setting state[0] = 'MT19937' just before the call to set_state and it seems to work fine, although this solution is obviously no good.
Minimal example:
import emcee
# File with posterior class:
import posterior as pos
posterior = pos.posterior()
filename = 'test.chains'
name = '000'
ndim = 3
nwalkers = 10
max_n = 10000
backend = emcee.backends.HDFBackend(filename, name=name)
sampler = emcee.EnsembleSampler(nwalkers, ndim, log_prob_fn=posterior.lnpos,
args=[[ns_range[0], ns_range[1]],[]], backend=backend)
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Converting to and from numpy's np.random.RandomState and ...
1 Answer 1 · the string 'MT19937'. · a 1-D array of 624 unsigned integer keys. · an integer pos. · an integer...
Read more >Best practice for pseudo random number generation in cython
The principle is that one master thread runs the MT19937 and generates random bits. These are written in chunks to fixed-size buffers. Then...
Read more >numpy/random/mtrand.pyx - Fossies
Raises ValueError if the underlying 266 bit generator is not an instance of MT19937. 267 268 Returns 269 ------- 270 out : {tuple(str,...
Read more >Sequence Classification with LSTM Recurrent Neural ...
Next, you need to truncate and pad the input sequences, ... The efficient ADAM optimization algorithm is used. ... create the model.
Read more >nugridpy.ppn
Samples are drawn from a binomial distribution with specified parameters, ... 0.27*15 = 4, so the binomial distribution should be used in this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I am seeing the same error, and the fix proposed above works for me as well (thanks @iipr for posting!).
emcee: 3.0.0, installed via conda python: 3.7.3 platform: Scientific Linux 7.7
Interesting. Thanks for reporting this. This definitely isn’t the expected behavior. I’ll look into this. What version of Python are you on, just so I know?