pyABC icon indicating copy to clipboard operation
pyABC copied to clipboard

Use local random state

Open yannikschaelte opened this issue 5 years ago • 1 comments

It is cleaner to manually define a random state, pass it to pyabc and then also to all workers (appropriately reinitialized). This would allow increasing the degree of reproducibility (there was an issue on that ...) and complies with numpy's new recommendations. https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html.

Suggest in addition allowing to pass a simple id resulting in a default Mersenne or whatever random number generator. TBD: What if the random package is used.

Also add documentation on seeding.

yannikschaelte avatar Jan 22 '21 15:01 yannikschaelte

Just to comment here, that using numpy's new SeedSequence and "spawning" seeds for each worker from that parent would probably be better than using np.random.randint() to generate the new seed for each worker. See these recommendations for "Parallel Random Number Generation" from Numpy: https://numpy.org/doc/stable/reference/random/parallel.html.

Alternatively, you can just rewrite the whole thing with JAX, and then you'll be forced to be reproducibly random 😏

JohnGoertz avatar Nov 20 '21 10:11 JohnGoertz