开发者

Reset Mersenne Twister

I assumed the answer to this is simple but at the moment it seems to be completely alluding me.

I'm using Mersenne Twister (implementation here http://www.bedaux.net/mtrand/) for generating random numbers.

I need it to be able to generate the same sequence of "random" numbers twice, straight after each other in the same program. I'm using the same void seed(const unsigned long*, int size); function with the same set of values in the hopes that this will reset the generator and allow开发者_如何学JAVA me to generate the same values again. Specifically:

unsigned long init[4] = {0x123, 0x234, 0x345, 0x456}, length = 4;
irand.seed(init, length);

Just to get this tested and working.

I was wondering if anyone has had this problem before.

Or knows what i'm doing wrong.


unsigned long init[4] = {0x123, 0x234, 0x345, 0x456};
int length = 4; 
MTRand_int32 irand(init, length);

irand.seed(init, length); // this resets

i've tested this by modifying the mtrand test program to reset after 5 numbers of output and the results were clear.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜