jwatte / node-mersenne

Node.js port of the Mersenne Twister random number generator
http://www.enchantedage.com/node-mersenne
BSD 3-Clause "New" or "Revised" License
12 stars 2 forks source link

can we have Jump Ahead method? #4

Open b051 opened 10 years ago

jwatte commented 10 years ago

What do you expect "Jump Ahead" to do? If I call "jumpAhead(10000)" what would the effect be, and what would the runtime be? Why is it better to have this method in the implementation, than just asking for 10000 bytes and throwing them away?

b051 commented 10 years ago

actually, I was hoping to get the Nth genrand_int32() after giving a seed, like,

m.init_genrand(saved_seed)
[0...N-1].forEach (n) -> m.genrand_int32()
expected = m.genrand_int32()

the reason is, so I can save the state of mt and continue next time.

b051 commented 10 years ago

I didn't read this C code carefully: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/JUMP/index.html, but someone referred it on stackoverflow when I search "Mersenne Twist Jump".