9.179 RANDOM_NUM_GENERATOR
Note: BuiltIn Function Rules Usage Options
Returns a random number between 0 and 1.
Arguments
No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

N

Opt

Stream index

1

2

0

0

2

N

Opt

Seed

1

10

0

0


Return Values
No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

N

Req

Random number between 0 and 1.

1

63

1

63


Technical Notes
 By default, the BuiltInFunction RANDOM_NUM_GENERATOR always returns a random number between 0 and 1. For advanced users, it also provides 100 independent streams of random numbers, where drawing a random number from one stream does not affect the sequence of random numbers drawn from a different stream. Each stream is referenced using an optional "stream index" in the range [0,99], inclusive. If no stream index is supplied, then stream 0 is used by default.
 By default, the BuiltInFunction RANDOM_NUM_GENERATOR seeds (i.e. initializes) each stream from the current system time the first time the stream is referenced. For advanced users, it also accepts an optional seed value which is used to seed (i.e. initialize) a stream. This is useful if you wish to repeat the same sequence of random numbers many times.
Examples
Get the next random number from the default stream (0):
Use Builtin(RANDOM_NUM_GENERATOR) To_Get(#x_dec)
Get the next random number from stream 23:
Use Builtin(RANDOM_NUM_GENERATOR) With_Args(23) To_Get(#x_dec)
Seed stream 42 with the value 12345. n.b. This seeds the stream and so will always return the same random number value:
Use Builtin(RANDOM_NUM_GENERATOR) With_Args(42 12345) To_Get(#x_dec)
Seed the default stream (0) with the value 56789.
Note: This seeds the stream and so will always return the same value:
Use Builtin(RANDOM_NUM_GENERATOR) With_Args(*DEFAULT 56789) To_Get(#x_dec)