JuliaRandom / JuliaRandom/RandomNumbers.jl
Seed sequence
- Lingua principale
- Julia
- Stelle
- 100
- Fork
- 23
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Previously I realized how bad the current implementation of using integers with small entropy to initialize a big-state RNG is. If we directly use small integers like 1, 2, 3 to be the initial states of xor-based RNGs (such as Xorshift), the starting sequences will probably poorly random. This is caused by the zeros in the state.
E.g.: https://sunoru.github.io/RNG.jl/latest/man/mersenne-twisters/#Examples-1
MT19937 uses an initialization function to avoid this situation. It performs a iterative transformation on one `UInt32` seed to generate a 623-`UInt32`s state. (And I still don't understand how people come up with the constants 1812433253 and 6364136223846793005)
C++'s `seed_seq` may be a valuable reference, although [this blog](http://www.pcg-random.org/posts/cpp-seeding-surprises.html) shows its flaws.
I have looked at how `dSFMT` and `libstdc++` deal with it:
https://github.com/MersenneTwister-Lab/dSFMT/blob/c6bf8a8dab3710b7abd86c4b68d0e6b4aa5e6db1/dSFMT.c#L554
https://github.com/atgreen/gcc/blob/76cc869aa9710764c7732d9bca0740fcf6865a27/libstdc%2B%2B-v3/include/bits/random.tcc#L3398
and they seem to be using similar methods..
@simonbyrne
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.