Random
- random number

Statistical functions
(AmiBroker 3.90)


SYNTAX Random( seed = Null )
RETURNS ARRAY
FUNCTION Returns an array of random values in 0..1 range (to get single random value use LastValue( Random() ) )
Seed is defined it initializes the seed of random number generator this allows to produce repetitive series of pseudo-random series. If seed is not specified - random number generator continues generation. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point.
EXAMPLE Example 1:

Graph0 = Random(); // generates different sequence with each refresh

Example 2:

Graph0 = Random(1); // generates the same sequence with each refresh

SEE ALSO   mtRandom() function

Comments:

Tomasz Janeczko
tj --at-- amibroker.com
2007-02-27 09:42:14
Internally Random() function uses Microsoft C runtime library rand() function scaled to cover 0..1 range:
(1.0*rand()/RAND_MAX)

Now Microsoft's rand() function (used in all MS languages) is Linear Congruential Pseudo-Random Number Generator coded using 32 bit integer arithmetic as follows:

static long holdrand;
int rand()
{
holdrand = holdrand * 214013 + 2531011;
return ( holdrand >> 16 ) & 0x7fff;
}

References:

The Random function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.