lundi 7 décembre 2015

Independent random number generators

I need to create independent random number generators in scala from a given one, something similar to haskell's split function. Can I use the current number generator to produce ints or longs, and use these as seed to create new generators?

val rng: Random 
val seed1 = rng.nextLong()
val seed2 = rng.nextLong()

val rng1 = new Random(seed1)
val rng2 = new Random(seed2)

Is this a good way to do it? Or does it screw the sequence of randomness (for example, by relying on Ints or Longs which may carry less information than the actual state of a random number generator)?




Aucun commentaire:

Enregistrer un commentaire