4.78 rand - Uniformly distributed random numbers

Format: ([Random seed])

Generate uniformly distributed random number from 0.0 to 1.0. This function returns the same result as using mrand command without -int option. The same random seed will generate the same sequence of random numbers. The random seed can be specified from -2147483648 to 2147483647. If the random seed is not defined, the random numbers will be seeded according to current time (1/1000 second). This function uses Mersenne Twister as random number generator (Author’s original website , boost library).

Examples

Example 1: Basic Example

Generate uniformly distributed random number from 0.0 to 1.0. Since a random seed is specified, the random number sequence generated is always the same.

$ more dat1.csv
id
1
2
3
4
$ mcal c='rand(1)' a=rsl i=dat1.csv o=rsl1.csv
#END# kgcal a=rsl c=rand(1) i=dat1.csv o=rsl1.csv
$ more rsl1.csv
id,rsl
1,0.4170219984
2,0.9971848081
3,0.7203244893
4,0.9325573612

Example 2: Random seed is not set

The random sequence will be different upon each run since random seed is not specified.

$ mcal c='rand()' a=rsl i=dat1.csv o=rsl2.csv
#END# kgcal a=rsl c=rand() i=dat1.csv o=rsl2.csv
$ more rsl2.csv
id,rsl
1,0.4007082446
2,0.8031022043
3,0.5551679884
4,0.9150564196