How to get a new, independent, randomly initialized RNG

question

#1

How can I get a randomly initialized RNG that is “independent” of Base.Random.GLOBAL_RNG (in the sense that I can use them in different threads in parallel)?

I thought of MersenneTwister(), but that is deprecated without an argument.

Is

srand(copy(Base.Random.GLOBAL_RNG))

the way to do it?


#2

It’s un-deprecated in 0.7. If you are on 0.6, an equivalent way is simply srand(MersenneTwister(0)). Equivalently, you can generate a random seed for MersenneTwister with e.g. seed = rand(RandomDevice(), UInt32, 4); rng = MersenneTwister(seed).


#3

This topic was automatically closed after 3 days. New replies are no longer allowed.