mercredi 31 juillet 2019

How to generate deterministic batches of pseudo-random numbers in python 3?

In python 3, random.jumpahead was deprecated (without much warning). How should this functionality be replaced?

I want to perform a large numerical experiment, aggregating many individual simulations:

  1. Each simulation is pseudo-random (i.e. internally depends at several points on PRNG input, which should be different and somewhat-independent for each simulation).
  2. My set of simulations is trivially-parallelisable, and so I want to be able to run separate simulations in different threads (or even as batch jobs on different machines at different times).
  3. I want to use a deterministic PRNG and a fixed seed, to ensure my results are reproducible (and do not depend on how the experiment is parallelised).

Previously these criteria were met by each simulation using the same seed but a unique jumpahead (based from an id or enumeration of the simulations). Is there a recommended alternative or should I still try to implement this approach?




Aucun commentaire:

Enregistrer un commentaire