The rnd() and ran() functions return a value between 0 and 1 from a uniformly distributed sample.
The initial starting value in the random number range is determined by a seed. The seed is a positive integer and can be set by rnd(seed)
or ran(seed)
.
Note: The seeding algorithm for Origin's methods of random number generation was changed for version 2016. For more information, see documentation for the system variable @ran. |
double rnd(int seed)
double ran(int seed)
seed
Returns a value between 0 and 1 from a uniformly distributed sample.
The sample script shows you how to set a seed and how to generate random numbers:
int seed = 1; ty "This outputs the same random number:"; for(int i = 1; i <= 3; i++) { if( rnd(seed) == 0 ) rnd() = ; } ty "This outputs a different random number each time:"; if( rnd(seed) == 0 ) { for(int i = 1; i <= 3; i++) { // First value is the same as above loop. rnd() = ; } }