![[About]](r:\html\rexxabout.gif)
![[Toc]](r:\html\rexxtoc.gif)
0.9b (c) 1995 Peter Childs
>>--RANDOM(-+--------------------------+-)----><
+-max----------------------+
+-min,-+-+-----+-+-------+-+
+-,----+ +-max-+ +-,seed-+
RANDOM returns a quasi-random, nonnegative whole number in the range min to max inclusive. If only one argument is specified, the range will be from 0 to that number. Otherwise, the default values for min and max are 0 and 999, respectively. A specific seed (which must be a whole number) for the random number can be specified as the third argument if repeatable results are desired.
The magnitude of the range (that is, max minus min) must not exceed 100000.
Here are some examples:
RANDOM() -> 305 RANDOM(5,8) -> 7 RANDOM(,,1983) -> 123 /* reproducible */ RANDOM(2) -> 0
Notes:
1. To obtain a predictable sequence of quasi-random numbers, use RANDOM
a number of times, but specify a seed only the first time. For
example, to simulate 40 throws of a six-sided, unbiased die, use:
sequence = RANDOM(1,6,12345) /* any number would */
/* do for a seed */
do 39
sequence = sequence RANDOM(1,6)
end
say sequence
The numbers are generated mathematically, using the initial seed, so
that as far as possible they appear to be random. Running the
program again will produce the same sequence; using a different
initial seed almost certainly produces a different sequence.
2. The random number generator is global for an entire program; the
current seed is not saved across internal routine calls.
3. The actual random number generator used may differ from
implementation to implementation.
Inf-HTML End Run - Successful