random (replaces TRandom)


The random function returns a 1-dimensional array containing random numbers distributed according to a uniform probability density function.

Syntax

tbl = random( nCount )

tbl = random( nCount, nMin, nMax )

bullet.gif    nCount is the number of random numbers.

bullet.gif    nCount is the number of random numbers in the range [ nMin, nMax ]. if omitted, the random numbers are created in the range [0, ..., 1 ].

bullet.gif    tbl is a 1-dimensional array containing nCount values, starting at index [1].

bullet.gif    On failure, nil is returned.

Example

The following script creates 1 million random numbers, creates a histogram of the values, and plots their histogram.

y = random( 1000000 )

-- create 1 million random deviates

H = new_histogram()

-- create a Histogram object

h = H:Calc( y )

-- compute the histogram

plot( x, h )

-- plot the histogram

H:delete()

 

Related Topics

Table and Array Functions, gaussdev, CStats class


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.