RandomTools - Maple Programming Help

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

RandomTools

 GetState
 Get the state of the RandomTools Generator

 Calling Sequence GetState( )

Description

 • The GetState command returns the internal state of the pseudo-random number generator used by Generate.  Currently the Mersenne Twister generator is used.
 • The state returned by GetState can be passed into SetState to regenerate a sequence of numbers.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\right)$
 $\left[{\mathrm{AddFlavor}}{,}{\mathrm{BlumBlumShub}}{,}{\mathrm{Generate}}{,}{\mathrm{GetFlavor}}{,}{\mathrm{GetFlavors}}{,}{\mathrm{GetState}}{,}{\mathrm{HasFlavor}}{,}{\mathrm{LinearCongruence}}{,}{\mathrm{MersenneTwister}}{,}{\mathrm{QuadraticCongruence}}{,}{\mathrm{RemoveFlavor}}{,}{\mathrm{SetState}}{,}{\mathrm{returnValueInertProc}}\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{Generate}\left(\mathrm{integer}\right),i=1..5\right)$
 ${-}{104281139460}{,}{-}{306860183579}{,}{-}{477575829529}{,}{300187484465}{,}{-}{72447943125}$ (3)
 > $\mathrm{SetState}\left(\mathrm{state}=s\right)$
 > $\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{integer}\right),i=1..5\right)$
 ${-}{104281139460}{,}{-}{306860183579}{,}{-}{477575829529}{,}{300187484465}{,}{-}{72447943125}$ (4)