jump ahead in Mersenne Twister

133 views
Skip to first unread message

Joaquim Masset Lacombe Dias Garcia

unread,
Oct 20, 2016, 8:43:05 PM10/20/16
to julia-users
Hi,

Have anybody implemented an arbitrary jump ahead for Mersenne Twister in julia?

I saw that the randjump documentation that goes as following:

randjump(r::MersenneTwister, jumps[, jumppoly]) → Vector{MersenneTwister}

Create an array of the size jumps of initialized MersenneTwister RNG objects where the first RNG object given as a parameter and following MersenneTwister RNGs in the array initialized such that a state of the RNG object in the array would be moved forward (without generating numbers) from a previous RNG object array element on a particular number of steps encoded by the jump polynomial jumppoly


Given that, my question would reduce to: how do I encode an arbitrary number of step (N) in a jumppoly ?

thanks!

Dan

unread,
Oct 21, 2016, 10:40:52 AM10/21/16
to julia-users
Hi Joaquim,

The jumppoly parameter to randjump is a string which depends on the specific parameters of the MersenneTwister. By default Julia uses the 19937 parameters in SFMT. To calculate these strings a utility was (or is still) supplied with SFMT called calc-jump. Its homepage is http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/JUMP/ . Compiling it is possible (I've managed to do so now), and then the command:
./calc-jump 100000000000000000000 poly.19937.txt
outputs the jumppoly used by Julia to setup multiple "independent" random generators (10^20 steps apart in the generator).
The smallest jump, by 1 step has the simple jumppoly equal to the string "2".
Finally, note that the Julia random generator can get two Float64s from each step of the Twister, and there is also a cache of about 382 Float64s, so jumping the Twister will not influence the generated random unless the cache is cleared and getting to the right position might require a *2 somewhere.
To setup a fixed jumppoly parameter of your choice, you should be able to use calc-jump. To do it dynamically in Julia would require ccall-ing the SFMT routine in SFMT Jump which is not too hard as well.

G'day, Dan Getz

Joaquim Masset Lacombe Dias Garcia

unread,
Oct 22, 2016, 6:04:34 PM10/22/16
to julia-users
 Thanks Dan,

I will try using the dSFMTjump lib!

best,
Reply all
Reply to author
Forward
0 new messages