DADiSP Worksheet Functions > Function Categories > Generated Series > GRANDOM

 

GRANDOM

Purpose:

Generates a random series based on a uniform or flat distribution. The optional range arguments let you determine the output range.

Syntax:

GRANDOM(length, spacing, rangelow, rangehigh)

length

-

An integer. The length of the output series.

spacing

-

A real, the spacing (delta x) between each point of the x-axis.

rangelow

-

Optional. A real, the low end of the range. Defaults to 0.0

rangehigh

-

Optional. A real, the high end of the range. Defaults to 1.0

Returns:

A series.

Example:

grandom(100,0.1,1,10)

 

generates a uniformly distributed random series of 100 points, spaced every 0.1 x-units, with values ranging from 1 to 10.

Example:

W1: grandom(50000, 1);label("Random Uniform")

W2: hist(w1, 30, "pdf");sety(0, 1.5);label("Histogram")

W3: gline(length(w2), deltax(w2), 0, 1);lines;overp(W2, lred);sety(0, 1.5);label("Unform Distribution")

 

 

W1 contains 50000 samples of uniformly distributed random values.

 

W2 contains a 30 sample normalized histogram of W1.

 

W2 compares the histogram to the analytic uniform distribution indicating that the random sequence in W1 is uniformly distributed.

Remarks:

If no range is given, default is [0,1]. If only one range is given, range is [0,range] or [range,0], depending on whether range is positive or negative.

 

The probability density function, f(x), for uniformly distributed random values over the interval [a,b] is:

 

 

 

The cumulative distribution function, F(x), for uniformly distributed random values is:

 

 

 

The mean is:

 

 

and the variance is:

 

 

 

See SEEDRAND to set a new seed value for the pseudo-random sequence.

 

GRANDOM can be abbreviated GRAND.

See Also:

GNORMAL

GRANDBINOMIAL

GRANDGAMMA

GRANDPOISSON

HISTOGRAM

RAND

RANDN

SEEDRAND