RandomTools[MersenneTwister] - Maple Programming Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Random Objects : RandomTools package : MersenneTwister Subpackage : RandomTools/MersenneTwister/GetState

RandomTools[MersenneTwister]

 GetState
 Get the internal state of the Mersenne Twister Generator

 Calling Sequence GetState( )

Description

 • The GetState command returns the internal state of the Mersenne Twister pseudo-random number generator.  The state is an rtable of type $\mathrm{integer}[4]$ with 625 entries.
 • The state returned by GetState can be passed into SetState to regenerate a sequence of numbers.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}[\mathrm{MersenneTwister}]\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[\begin{array}{c}{\mathrm{0 .. 624}}{\mathrm{Array}}\\ {\mathrm{Data Type:}}{\mathrm{integer}}{[}{4}{]}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (2)
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${395718860534}{,}{193139816415}{,}{22424170465}{,}{800187484459}{,}{427552056869}$ (3)
 > $\mathrm{SetState}\left(\mathrm{state}=s\right)$
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${395718860534}{,}{193139816415}{,}{22424170465}{,}{800187484459}{,}{427552056869}$ (4)

Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam