RANDOM_MT64_INIT Procedure (PV-WAVE Advantage)
Initializes the 64-bit Mersenne Twister generator using an array.
Usage
RANDOM_MT64_INIT, key
Input Parameters
key—An array of integers with at least two elements used to initialize the 64-bit Mersenne Twister generator.
Discussion
By default, the Mersenne Twister generator is initialized using 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 procedure allows an arbitrary length array to be used for initialization.
This procedure completely replaces the use of the seed for initialization of the 64-bit Mersenne Twister generator.
Example
init = ['123'XL, '234'XL, '345'XL, '456'XL]
iseed = 123457L
nr = 5L
; Initialize the 64-bit Mersenne Twister series with a seed
RANDOMOPT, Gen_opt=9, Set=iseed
r = RANDOM(nr, /Uniform)
PRINT,""
PRINT," First Stream Output:"
PRINT,r
; Reinitialize 64-bit Mersenne Twister series with an array
RANDOM_MT64_INIT, init
; Save the state of the series.
RANDOM_TABLE, table, /Get, /Mt64
r = RANDOM(nr, /Uniform)
PRINT,""
PRINT," Second Stream Output:"
PRINT,r
; Restore the state of the series
RANDOM_TABLE, table, /Set, /Mt64
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, /Set, /Mt64
r = RANDOM(nr, /Uniform)
PRINT,""
PRINT," Fourth Stream Output:"
PRINT,r
Output
First Stream Output:
0.579917 0.940115 0.710159 0.163995 0.545669
Second Stream Output:
0.489402 0.739650 0.572506 0.0862636 0.758835
Third Stream Output:
0.489402 0.739650 0.572506 0.0862636 0.758835
Fourth Stream Output:
0.579917 0.940115 0.710159 0.163995 0.545669
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.