mercredi 12 mai 2021

How to produce pseudo-random numbers based of a seed with the Rust rand crate reproducible for all platforms?

Basically this is a follow-up question to this question. In this answer, it is stated, that if reproducibility across builds and architectures is desired,

then look at crates such as rand_chacha, rand_pcg, rand_xoshiro

The same is stated in the documentation for StdRng:

The algorithm is deterministic but should not be considered reproducible due to dependence on configuration and possible replacement in future library versions. For a secure reproducible generator, we recommend use of the rand_chacha crate directly.

I have looked at these crates, but I have not found out how to use them for my use case. I am looking for a small sample showing how one of these crates can be used for generating a sequence of pseudo-random numbers, that are always the same for a given seed.




Aucun commentaire:

Enregistrer un commentaire