RANDOMOPT Procedure
Sets or retrieves the random number seed to select the uniform (0, 1) multiplicative, congruential pseudorandom-number generator.
Usage
RANDOMOPT
Input Parameters
Procedure RANDOMOPT does not have any positional input parameters. Keywords are required for specific actions to be taken.
Keywords
Gen_Option—An indicator of the generator. The random-number generator is a multiplicative, congruential generator with modulus 231 – 1. Keyword Gen_Option is used to choose the multiplier and to determine whether or not shuffling is done.
*1—multiplier 16807 used (default)
*2—multiplier 16807 used with shuffling
*3—multiplier 397204094 used
*4—multiplier 397204094 used with shuffling
*5—multiplier 950706376 used
*6—multiplier 950706376 used with shuffling
Get—A named variable into which the value of the current random-number seed is stored.
Set—The seed of the random-number generator. The seed must be in the range (0, 2147483646). If the seed is zero, a value is computed using the system clock; hence, the results of programs using the random-number generators are different at various times.
 
Discussion
RANDOMOPT is designed to allow you to set certain key elements of the random-number generator function RANDOM.
The uniform pseudorandom-number generators use a multiplicative congruential method, with or without shuffling. The value of the multiplier and whether or not to use shuffling are determined by keyword Gen_Option. The description of function RANDOM may provide some guidance in the choice of the form of the generator. If no selection is made explicitly, the generators use the multiplier 16807 without shuffling. This form of the generator has been in use for some time (Lewis et al. 1969).
Keyword Set is used to initialize the seed used in the random-number generators. The form of the generators follows:
xi = cxi – 1 mod (231 – 1)
The value of x0 is the seed. If the seed is not initialized prior to invocation of any of the routines for random-number generation by calling RANDOMOPT, the seed is initialized via the system clock. The seed can be re-initialized to a clock-dependent value by calling RANDOMOPT with Set set to zero.
A common use of keyword Set is in conjunction with the keyword Get to restart a simulation. Keyword Get retrieves the current value of the “seed” used in the random-number generators.
Example
This example illustrates the statements required to restart a simulation using the keywords Get and Set. The example shows that restarting the sequence of random numbers at the value of the last seed generated is the same as generating the random numbers all at once.
seed = 123457
nrandom = 5
; Set the seed using the keyword Set.
RANDOMOPT, Set = seed
r1 = RANDOM(nrandom)
PM, r1, Title = 'First Group of Random Numbers'
; PV-WAVE prints the following:
; First Group of Random Numbers
; 0.966220
; 0.260711
; 0.766262
; 0.569337
; 0.844829
; Get the current value of the seed using the keyword Get.
RANDOMOPT, Get = seed
RANDOMOPT, Set = seed
r2 = RANDOM(nrandom)
PM, r2, Title = 'Second Group of Random Numbers'
; PV-WAVE prints the following:
; Second Group of Random Numbers
; 0.0442665
; 0.987184
; 0.601350
; 0.896375
; 0.380854
; Reset the seed to the original seed.
RANDOMOPT, Set = 123457
r3 = RANDOM(2 * nrandom)
PM, r3, Title = 'Both Groups of Random Numbers'
; PV-WAVE prints the following:
; Both Groups of Random Numbers
; 0.966220
; 0.260711
; 0.766262
; 0.569337
; 0.844829
; 0.0442665
; 0.987184
; 0.601350
; 0.896375
; 0.380854
See Also
For Additional Information
Lewis, Goodman and Miller, 1969