The IMSL_RANDOM_TABLE procedure sets or retrieves the current table used in either the shuffled or GFSR random number generator.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

The values in table are initialized by the IMSL random number generators. The values are all positive except if you want to reinitialize the array, in which case the first element of the array is input as a nonpositive value. (Usually, one should avoid reinitializing these arrays, but it might be necessary sometimes in restarting a simulation.) If the first element of table is set to a nonpositive value on the call to IMSL_RANDOM_TABLE with the keyword SET, on the next invocation of a routine to generate random numbers, the appropriate table will be reinitialized.

For more details on the shuffled and GFSR generators see the Overview of Random Number Generation.

Example


In this example, three separate simulation streams are used, each with a different form of the generator. Each stream is stopped and restarted. (Although this example is obviously an artificial one, there may be reasons for maintaining separate streams and stopping and restarting them because of the nature of the usage of the random numbers coming from the separate streams.)

nr = 5
iseed1 = 123457
iseed2 = 123457
iseed7 = 123457
 
; Begin first stream, iopt = 1 (by default)
IMSL_RANDOMOPT, Set = iseed1
r = IMSL_RANDOM(nr)
IMSL_RANDOMOPT, Get = iseed1
PM, r, TITLE = 'First stream output'
 
First stream output
  0.966220
  0.260711
  0.766262
  0.569337
  0.844829
PRINT, 'output seed ', iseed1 output seed 1814256879
 
; Begin second stream, iopt = 2
IMSL_RANDOMOPT, gen_opt = 2
IMSL_RANDOMOPT, Set = iseed2
r = IMSL_RANDOM(nr)
IMSL_RANDOMOPT, Get = iseed2
IMSL_RANDOM_TABLE, table, /Get
PM, r, TITLE = 'Second stream output'
 
Second stream output
  0.709518
  0.186145
  0.479442
  0.603839
  0.379015
PRINT, 'output seed ', iseed2 output seed 1965912801
 
; Begin third stream, iopt = 7
IMSL_RANDOMOPT, gen_opt = 7
IMSL_RANDOMOPT, Set = iseed7
r = IMSL_RANDOM(nr)
IMSL_RANDOMOPT, Get = iseed7
IMSL_RANDOM_TABLE, itable, /Get, /GFSR
PM, r, TITLE = 'Third stream output'
 
Third stream output
  0.391352
  0.0262676
  0.762180
  0.0280987
  0.899731
 
PRINT, 'output seed ', iseed7 output seed 1932158269
 
; Reinitialize seed and resume first stream
IMSL_RANDOMOPT, gen_opt = 1
IMSL_RANDOMOPT, Set = iseed1
r = IMSL_RANDOM(nr)
IMSL_RANDOMOPT, Get = iseed1
PM, r, TITLE = 'First stream output'
 
First stream output
  0.0442665
  0.987184
  0.601350
  0.896375
  0.380854
 
PRINT, 'output seed ', iseed1 output seed 817878095
 
; Reinitialize seed & table for shuffling & resume second stream
IMSL_RANDOMOPT, gen_opt = 2
IMSL_RANDOMOPT, Set = iseed2
IMSL_RANDOM_TABLE, table, /Set
r = IMSL_RANDOM(nr)
IMSL_RANDOMOPT, Get = iseed2
PM, r, TITLE = 'Second stream output'
 
Second stream output
  0.255690
  0.478770
  0.225802
  0.345467
  0.581051
 
PRINT, 'output seed ', iseed2 output seed 2108806573
 
; Reinitialize seed and table for GFSR and resume third stream.
IMSL_RANDOMOPT, GEN_OPT = 7
IMSL_RANDOMOPT, SET = iseed7
IMSL_RANDOM_TABLE, itable, /SET, /GFSR
r = IMSL_RANDOM(nr)
IMSL_RANDOMOPT, GET = iseed7
PM, r, TITLE = 'Third stream output'
 
Third stream output
  0.751854
  0.508370
  0.906986
  0.0910035
  0.691663
 
PRINT, 'output seed ', iseed7 output seed 1485334679

Syntax


IMSL_RANDOM_TABLE, Table [, /DOUBLE] [, /GET | /SET] [, /GFSR]

Return Value


None

Arguments


Table

One dimensional array used in the generators. For the shuffled generators table is length 128. For the GFSR generator table is length 1565. The argument table is input if the keyword SET is used, and output if the keyword GET is used.

Keywords


DOUBLE (optional)

If present and nonzero, double precision is used. This keyword is active only when the shuffled table is being set or retrieved.

GET (optional)

If present and nonzero, then the specified table is being retrieved.

GFSR (optional)

If present and nonzero, then the specified GFSR table is being set or retrieved.

SET (optional)

If present and nonzero, then the specified table is being set.

Version History


6.4

Introduced

See Also


IMSL_RANDOMOPT, IMSL_RAND_GEN_CONT, IMSL_RAND_GEN_DISCR, Overview of Random Number Generation