randomize - Maple Programming Help

Home : Support : Online Help : Programming : Random Objects : randomize

randomize

reset the seed for random number generators

 Calling Sequence randomize(r)

Parameters

 r - (optional) positive integer

Description

 • With a positive integer as an argument, randomize(n) will use the given value to initialize the state in the default random number generator. With no arguments, randomize() will use a number based on the system clock to initialize the state of the random number generator.
 • The return value will be the seed used to initialize the state of the random number generator.  If n is specified the return value is n.
 • randomize calls RandomTools[MersenneTwister][SetState].  It is more efficient to make this call directly than to call randomize.
 • By passing the value returned by randomize into a subsequent call to randomize the same sequence of numbers will be generated.
 • Since the no argument form of randomize() depends on the system clock, the same seed can be obtained if not enough time elapses between two consecutive calls to randomize().

Examples

 > $\mathrm{Seed}≔\mathrm{randomize}\left(\right)$
 ${\mathrm{Seed}}{≔}{15120076480}$ (1)
 > $\mathrm{rand}\left(\right)$
 ${292369167028}$ (2)
 > $\mathrm{rand}\left(\right)$
 ${412668408698}$ (3)
 > $\mathrm{randomize}\left(\mathrm{Seed}\right)$
 ${15120076480}$ (4)
 > $\mathrm{rand}\left(\right)$
 ${292369167028}$ (5)