mercredi 31 juillet 2019

Why does MersenneTwister seem to generate different sequences for the same seed?

Executing:

using Random

rng1 = MersenneTwister(42)
rng2 = MersenneTwister(42)

v = [ x for _ = 1:4, x = rand(rng1) ]
w = [ rand(rng2) for _ = 1:4 ]

print("$(v)\n$(w)\n")

generates the following output:

[0.533183, 0.533183, 0.533183, 0.533183]
[0.533183, 0.454029, 0.0176868, 0.172933]

Shouldn't the two sequences be the same? What am I missing?

I get identical results on multiple systems, and with no regard to whether I create v first or w.




Aucun commentaire:

Enregistrer un commentaire