IDL

RANDOMN

RANDOMN

The RANDOMN function returns one or more pseudorandom numbers from a normal (Gaussian) distribution with a mean of zero and a standard deviation of one. Using the RANDOMN function is equivalent to using RANDOMU with the /NORMAL keyword, and is provided as a programming convenience.

RANDOMN uses the Box-Muller method, based off of the gasdev algorithm1 . The uniform random numbers required for the Box-Miller method are generated using the Mersenne Twister algorithm. See RANDOMU for more discussion of the random number generator.

Note: For Seed values equal to a non-whole number, such as float, RANDOMN uses the whole number portion of the constant Seed. For example, entering 7.0 as the Seed produces the same result as using 7.5 or 7.9.

Example


To create a 10 by 10 array of normally-distributed, random numbers, type:

R = RANDOMN(seed, 10, 10)

Plot the probability function of random numbers:

x = RANDOMN(SEED, 100000)
h = HISTOGRAM(x, BINSIZE=0.1, LOCATIONS=hlocs)
p = BARPLOT(hlocs, h)

Distribution of random numbers generated with RANDOMN

Syntax


Result = RANDOMN( Seed[D1[, ..., D8]] [, /DOUBLE] [, /RAN1] )

Return Value


Returns an array containing the random numbers of the specified dimensions.

Arguments


Seed

A variable or constant used to initialize the random sequence on input, and in which the state of the random number generator is saved on output. See the Seed argument in RANDOMU for details.

Di

Either an array or a series of scalar expressions specifying the dimensions of the result. If a single argument is specified, it can be either a scalar expression or an array of up to eight elements. If multiple arguments are specified, they must all be scalar expressions. Up to eight dimensions can be specified. If no dimensions are specified, RANDOMN returns a scalar result.

Keywords


DOUBLE

Set this keyword to return a double-precision random number. See the DOUBLE keyword in RANDOMU for details on how the double-precision numbers are constructed.

RAN1

Set this keyword to use the older ran1 algorithm, which was the default in IDL 8.1 and earlier. See RANDOMU for details on the old algorithm.

Version History


Original

Introduced

8.2.2 Changed to use the Mersenne Twister algorithm, added RAN1 keyword. Deprecated BINOMIAL, GAMMA, LONG, NORMAL, POISSON, UNIFORM keywords. These keywords will continue to work, but new code should use the RANDOMU function instead.

See Also


RANDOMU

Resources and References


1. See Section 7.2 of Numerical Recipes in C: The Art of Scientific Computing (Second Edition), Cambridge University Press, 1992.



Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions