SetState - Maple Help

RandomTools[MersenneTwister]

 SetState
 Set the internal state of the Mersenne Twister Generator

 Calling Sequence SetState( option )

Parameters

 option - (optional) argument of the form option=value where option is state

Description

 • The SetState command sets the state of the internal Mersenne Twister random number generator.
 • A state returned by GetState can be passed into SetState to regenerate a sequence of numbers.
 • SetState accepts one optional argument, state.
 state=integer or rtable
 The state argument specifies the data used to set the state of the generator.  If the value of state is an integer, then the integer is used to seed the state.  If the value of state is an rtable that was returned by GetState, then the state is set to the value stored in the rtable.  If the state argument is not given then the state is seeded using values taken from the system.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\left[\mathrm{MersenneTwister}\right]\right)$
 $\left[{\mathrm{GenerateData}}{,}{\mathrm{GenerateFloat}}{,}{\mathrm{GenerateFloat64}}{,}{\mathrm{GenerateInteger}}{,}{\mathrm{GenerateInteger32}}{,}{\mathrm{GenerateUnsignedInt32}}{,}{\mathrm{GetState}}{,}{\mathrm{NewGenerator}}{,}{\mathrm{SetState}}\right]$ (1)
 > $s≔\mathrm{GetState}\left(\right)$
 ${s}{≔}\left[{5489}{,}{1301868182}{,}{-1356468075}{,}{-1344685418}{,}{1875628136}{,}{751856242}{,}{944701696}{,}{-2051775225}{,}{694061057}{,}{219885934}{,}{2066767472}{,}{-1112097888}{,}{485472502}{,}{-1958109413}{,}{1071588843}{,}{-876496698}{,}{951210697}{,}{-601408930}{,}{-1371485245}{,}{1793174584}{,}{-1312656495}{,}{1586906132}{,}{1951078751}{,}{1808158765}{,}{1733897588}{,}{431328322}{,}{-92428252}{,}{530658942}{,}{1714810322}{,}{-1269711012}{,}{-952381900}{,}{1937033938}{,}{-1654394785}{,}{1654299090}{,}{-602563743}{,}{-61095987}{,}{-797316502}{,}{862629010}{,}{-1351731264}{,}{-1868508751}{,}{1603307207}{,}{1133453895}{,}{-1195770936}{,}{-2086309667}{,}{-1547313369}{,}{931059398}{,}{761573964}{,}{-1137114069}{,}{785880413}{,}{730313442}{,}{124945756}{,}{-1357850241}{,}{-998984827}{,}{1724353043}{,}{-1273291952}{,}{-410080879}{,}{-284817198}{,}{-238005330}{,}{699635835}{,}{-1613628478}{,}{1339167484}{,}{720757518}{,}{-1494805820}{,}{-1918869923}{,}{1532957371}{,}{-392303197}{,}{1238982754}{,}{-569572782}{,}{-845790407}{,}{-724004825}{,}{-7331206}{,}{-207660284}{,}{-691623669}{,}{202242161}{,}{-1299284513}{,}{1620962684}{,}{-590243939}{,}{371613603}{,}{-1480132963}{,}{2111005706}{,}{624778151}{,}{2094172212}{,}{-10020293}{,}{1211977835}{,}{991917094}{,}{1570449747}{,}{-1332596816}{,}{1259410321}{,}{170182696}{,}{146300961}{,}{-1458137505}{,}{619452428}{,}{-1571297000}{,}{1881399711}{,}{1161269684}{,}{1675188680}{,}{-162792019}{,}{780088327}{,}{-885504475}{,}{1036518241}{,}{\dots }{,}{\text{⋯ 525 Array(0 .. 624) entries not shown}}\right]$ (2)
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${395718860534}{,}{193139816415}{,}{22424170465}{,}{800187484459}{,}{427552056869}$ (3)
 > $\mathrm{SetState}\left(\mathrm{state}=1234567\right)$
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${633358104191}{,}{499773630790}{,}{300352444386}{,}{416305631357}{,}{412579138445}$ (4)
 > $\mathrm{SetState}\left(\mathrm{state}=1234567\right)$
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${633358104191}{,}{499773630790}{,}{300352444386}{,}{416305631357}{,}{412579138445}$ (5)
 > $\mathrm{SetState}\left(\mathrm{state}=s\right)$
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${395718860534}{,}{193139816415}{,}{22424170465}{,}{800187484459}{,}{427552056869}$ (6)