Random number generators discussion

Random number generators | www.agner.org

Mersenne Twister
Author:  Date: 2004-05-18 15:51
Hi all:

I have been studying the original MT code, mt19937.c and the improved version, mt19937ar.c. My understanding is that the difference is in using two initialization routines, sgenrand() vs init_genrand(). The sgenrand() function can produce output sequences that are highly correlated if two initial states are not chosen correctly, while the new function doesn't have that problem. Is this a correct understanding? I am also trying to find two initial states (or maybe two initial seeds?) that will produce highly non-random sequences of numbers using the sgenrand() function in mt19937.c to demonstrate this phenomena. Does anyone know if there is a good way to find such two seeds?

Thank you very much and any help will be greatly appreciated.

FC

void
sgenrand(seed)
unsigned long seed;
{
/* setting initial seeds to mt[N] using */
/* the generator Line 25 of Table 1 in */
/* [KNUTH 1981, The Art of Computer Programming */
/* Vol. 2 (2nd Ed.), pp102] */
mt[0]= seed & 0xffffffff;
for (mti=1; mti<N; mti++)
mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
}


void init_genrand(unsigned long s)
{
mt[0]= s & 0xffffffffUL;
for (mti=1; mti<N; mti++) {
mt[mti] =
(1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array mt[]. */
/* 2002/01/09 modified by Makoto Matsumoto */
mt[mti] &= 0xffffffffUL;
/* for >32 bit machines */
}
}

 
thread Mersenne Twister - Fang Chen - 2004-05-18
last replythread Mersenne Twister new - Agner - 2004-05-19
last replythread Mersenne Twister new - Fang Chen - 2004-05-19
last reply Mersenne Twister new - Agner - 2004-05-20