random_uniform
Generates random numbers using a uniform range distribution.
Prototype
function random_uniform ( low [1] : numeric, high [1] : numeric, N [*] : integer ) return_val [dimsizes(N)] : float or double
Arguments
lowScalar representing low bound (exclusive) on real values to be generated.
highScalar representing high bound (exclusive) on real values to be generated.
NDimensions of the multi-dimensional array to be generated.
Return value
Returns an array of random numbers dimensioned the same as N.
The return type is floating point if the input is floating point, and double if the input is of type double.
Description
This function generates an array of random numbers from the range (0, 1) using a uniform distribution. If the user does not explicitly set initial values for seeds via random_setallseed, those initial seeds will be set to default values. It is recommended that the user specify these seeds. The source of this random number generator is from the random section at Netlib. The authors were Brian Brown and James Lovato. The official reference is:
Authors: P. L'Ecuyer and S. Cote
Title: Implementing a Random Number Package with Splitting Facilities
Journal: ACM Transactions on Mathematical Software 17:1, pp 98-111.
See Also
random_chi, random_gamma, random_normal, random_setallseed
Examples
Example 1
Generate random deviates:
begin random_setallseed(36484749, 9494848) ; Set seeds (suggested, NOT required) low = -1.0 high = 1.0 unf = random_uniform(low, high, (/10, 64, 128/)) ; uniform(10, 64, 128) endExample 2
Let U(18, 64, 128), and assume the user wishes to perturb these values by a max of 1%:
random_setallseed(363738674, 918273645) ; Set seeds (suggested, NOT required) low = 0.99 high = 1.01 dimU = dimsizes(U) unf = random_uniform(low, high, dimU) ; uniform(18, 64, 128) U = U * unf ; element by element multiply