Comparing random sequences between Julia, Numpy, MATLAB

statistics

#1

Is there a way to set the rng’s in Julia, Numpy, and MATLAB to produce the same sequence? I’m not looking to do something fancy with multithreading, I just want to compare/debug output where all codes are producing the same sequence with, for instance, the default Mersenne Twister algorithm.


#2

I would just generate it in one language and load it into the others.


#3

Even with the exact same stream of random numbers, you may not get exactly the same results in different languages. Especially if some calculations are nonlinear (eg branches on values). Even using the same version of Julia & libraries with the same RNG seed on two different machines can get you different results.


#4

See also some previous discussion here: Rand in Julia vs MATLAB