AdvancedPS.jl
AdvancedPS.jl copied to clipboard
Carefully handle splitting of RNG seeds
There are several instances in the codebase where we have to create N pseudo-random number generators from one, for example:
https://github.com/TuringLang/AdvancedPS.jl/blob/d0d180f432a6e2bf2fdd08c35d25ea2ef7715d4f/src/container.jl#L121-L136
Right now, this is handled by split, which generates new seeds to be used with new PRNGs.
https://github.com/TuringLang/AdvancedPS.jl/blob/d0d180f432a6e2bf2fdd08c35d25ea2ef7715d4f/src/rng.jl#L33-L42
This is not always a reliable method as the new seeds may end up accidentally generating highly correlated sequences of numbers. See, e.g., https://gee.cs.oswego.edu/dl/papers/oopsla14.pdf
We should therefore switch to an underlying RNG type that supports splitting. (Note that right now, we are using Philox2x [paper, library] but the library does not implement a split function, even though it should theoretically be possible. Compare e.g. with Numpy's implementation, which provides a jumped method for this purpose.)