|
|||||
|
||||||
Other Library Functions |
function |
random.set-seed |
Library: Random number utilities (OMRANDOM)
Import: omrandom.xmd |
define external function random.set-seed to value integer seed
This function provides a seed to prime the random number generator. Different seed values will produce different sequences of numbers.
By using the same seed for each run, the sequence of pseudo-random numbers can be kept the same. If the application is using random numbers to perform some kind of simulation, the simulation can be repeated by supplying the same seed.
This program will generate a different sequence of
numbers each time, because the seed is always different:
import "omutil.xmd" prefixed by util. import "omrandom.xmd" prefixed by random. process local integer seed initial {util.millisecond-time} output "The seed is: %d(seed)%n" random.set-seed to seed repeat for integer i to 100 output "d" % i || ". " || "d" % random.uniform || "%n" again
This program will generate the same sequence of
numbers each time, because the seed is always 12345:
import "omrandom.xmd" prefixed by random. process local integer seed initial {12345} output "The seed is: %d(seed)%n" random.set-seed to seed repeat for integer i to 100 output "d" % i || ". " || "d" % random.uniform || "%n" again
Other Library Functions
|
Copyright © Stilo International plc, 1988-2010.