Closed avivajpeyi closed 2 years ago
Hi @avivajpeyi ,
This and many other things have been fixed here https://github.com/joshspeagle/dynesty/issues/254
Relevant commits are here https://github.com/joshspeagle/dynesty/pull/292
You just need to use the new style numpy random generators. (i.e. np.random.default_rng(xx))
I'm pretty certain that now dynesty is 100% deterministic.
Hmmm changing np.random.RandomState(seed=0)
to np.random.default_rng(seed=0)
results in some errors:
for attempt in range(100):
> live_u = rstate.rand(nlive, npdim) # positions in unit cube
E AttributeError: 'numpy.random._generator.Generator' object has no attribute 'rand'
However, running the above script (of the linear regression example) does indeed provide reproducible results!
,
You have to use dynesty master branch (as 1.2 is still not released... )
I think, you'd have to test that the answer are EXACTLY equal, not approximately. And given that, there is no need imo for more than two runs. Also the problem with this kind of test (and the reason i didn't commit something like that before) is that there are many different code paths that involve randomness (different samplers etc) and it's a bit too time-consuming to test them all.
In fact you test is incorrect. you need to have get_rstate(SOME_NUMBER) inside the loop.
I've added a test that verifies that all the results attributes are the exactly the same when run with the same rstate https://github.com/joshspeagle/dynesty/commit/162d66813f85b830059f1722359364d5598b6b50 Thanks for the PR @avivajpeyi
Hey @joshspeagle and @segasai ,
Some devs and I at Monash Uni are having some trouble getting reproducible results with the same
rstate
. This PR includes a small test to demonstrate this issue, and hopefully check for it in the future.Here is also a script that plots N sampling results from the linear regression example, both using the same data and same sampling seed.
Note that the
runplot
s for the two runs look rather different:Is this a known feature? How can I set my rstate such that I can reproduce a run identically?