Next: randomb, Previous: quit, Up: Internal Routines [Contents][Index]

`random( [seed=`

`seed`, period=`period`,] [`dimensions`] [,
/uniform, /normal, /sample, /shuffle, /bits])

Returns an array with the specified

(which must
be a set of `dimensions``scalar`

s and/or `array`

s) filled with
pseudo-random numbers. The keywords determine the distribution. If no
keyword is specified, then `/uniform`

is assumed.

`/uniform`

selects a uniform distribution. If

is also specified, then`period``long`

numbers between 0 and

- 1 (inclusive) are returned. If`period`

is not also specified, then`period``float`

numbers between 0 and 1 (exclusive of the endpoints) are returned.`/normal`

selects a normal distribution with zero mean and unit standard deviation.

`/sample`

selects a uniform distribution between 0 and

- 1 (inclusive), but the numbers are in ascending order and no number appears more than once.`period``/shuffle`

selects a uniform distribution between 0 and

- 1 (inclusive), but no number appears more than once and they are in random order.`period``/bits`

selects

`byte`

0s and 1s with equal probability.

is an integer seed number for the random number
generation: if you specify the same seed, then you get the same sequence
of random numbers. There is one seed for `seed``/bits`

and one
independent seed for the other distributions. The initial seed is
`123459876`

for `/bits`

and `-123459876`

for the other
distributions. You may specify a seed and no dimensions in calls to
`random`

or any of its cousins. It that case, the seed is set to
the specified value, and a scalar `1`

is returned.

There are several separate routines that correspond to `random`

with a particular distribution.

The pseudo-random numbers generated when `/bits`

is selected follow
from a primitive polynomial modulo 2 with a period of `2^31 - 1`

,
or about `2.1e9`

.

The method used to generate the pseudo-random numbers with other
distributions is Matsumoto and Nishimura’s “Mersenne Twister” mt19937
generator. The period of this generator is `2^19937 - 1`

, or about
`1e6000`

.

See also: randomb, randomn, randomu, Random Arrays

Next: randomb, Previous: quit, Up: Internal Routines [Contents][Index]