MATLAB: How to seed Mersenne Twister rng to get the same state as in the C implementation

crng

Hi,
When I init the Mersenne Twister RNG in Matlab and C ( http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c ) with the same seed, I get different states. Is there a way to get the same state in both?

Best Answer

When you call rng with an argument, the return value is the previous state. You need to call it again with no argument to get the current state after setting the seed.