RANDOM_MT32_INIT Procedure
Initializes the 32-bit Mersenne Twister generator using an array.
Usage
RANDOM_MT32_INIT, key
Input Parameters
key—An array of integers with at least two elements used to initialize the 32-bit Mersenne Twister generator.
Discussion
By default, the Mersenne Twister generator is initialized using the system clock via RANDOMOPT. The Set keyword to RANDOMOPT may also be used to define a scalar seed value. The seed is limited to one integer for initialization. This function allows an arbitrary length array to be used for initialization.
This function completely replaces the use of the seed for initialization of the 32-bit Mersenne Twister generator.
Example
init = ['123'XL, '234'XL, '345'XL, '456'XL]
iseed = 123457L
nr = 5L
 
; Initialize the Mersenne Twister series with a seed
RANDOMOPT, Gen_opt=8, Set=iseed
r = RANDOM(nr, /Uniform)
PRINT,""
PRINT,"           First Stream Output:"
PRINT,r
 
; Reinitialize 32-bit Mersenne Twister series with an array
RANDOM_MT32_INIT, init
 
; Save the state of the series.
RANDOM_TABLE, table, /Get, /Mt32
r = RANDOM(nr, /Uniform)
PRINT,""
PRINT,"          Second Stream Output:"
PRINT,r
 
; Restore the state of the series
RANDOM_TABLE, table, /Set, /Mt32
r = RANDOM(nr, /Uniform)
PRINT,""
PRINT,"          Third Stream Output:"
PRINT,r  
 
; Reset the series - it will reinitialize from the seed
table(0) = 1000L
RANDOM_TABLE, table, /Mt32, /Set
r = RANDOM(nr, /Uniform)
PRINT,""
PRINT,"          Fourth Stream Output:"
PRINT,r 
Output
          First Stream Output:
   0.434745     0.352209    0.0138511     0.209141     0.495600
 
          Second Stream Output:
   0.248569     0.222573     0.111128     0.956286     0.984635
 
          Third Stream Output:
   0.248569     0.222573     0.111128     0.956286     0.984635
 
          Fourth Stream Output:
   0.434745     0.352209    0.0138511     0.209141     0.495600