Skip to content

RFC: Replace Pcg64 by Xoshiro256++ to avoid issues of self-correlation

Adam Reichold requested to merge replace-pcg-by-xoshiro into bump-rand-ecosystem

The PCG generators show problematic self-correlation when seeded inappropriately so that only the lower 64 bits of the 128 bit seed differ. However, seeding is rather opaque here as seed a PRNG for each process/subworld using the rand crate's SeedableRng::from_rng function.

While this does currently seem to ensure sufficient mixing to avoid the above issue as testing using the PractRand test suite, there is a simpler alternative when a jumpable PRNG like Xoshiro256++ is used which allows to create sufficiently many sufficiently long non-overlapping streams for each process.

Another benefit is that Xoshiro256++ has slightly better performance. It also has become the endorsed SmallRng provided by the rand crate which further increases its credibility.

The major downsides seem to be that Xoshiro256++ is a bit younger, published in 2019 compared to Pcg64 which was first described in 2014, and of course that the model output before and after this change is not comparable when the same seed (and number of processes) is used.

Edited by Adam Reichold

Merge request reports