 RandomTools[LinearCongruence] - Maple Programming Help

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

RandomTools[LinearCongruence]

 GetState
 Get the internal state of the Linear Congruence Generator

 Calling Sequence GetState( )

Description

 • The GetState command returns the internal state of the Linear Congruence pseudo-random number generator.  The state is an integer.
 • The state returned by GetState can be passed into SetState to regenerate a sequence of numbers.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\left[\mathrm{LinearCongruence}\right]\right)$
 $\left[{\mathrm{GenerateInteger}}{,}{\mathrm{GetState}}{,}{\mathrm{NewGenerator}}{,}{\mathrm{SetState}}\right]$ (1)
 > $s≔\mathrm{GetState}\left(\right)$
 ${s}{≔}{1}$ (2)
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${427419669081}{,}{321110693270}{,}{343633073697}{,}{474256143563}{,}{558458718976}$ (3)
 > $\mathrm{SetState}\left(\mathrm{state}=s\right)$
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${427419669081}{,}{321110693270}{,}{343633073697}{,}{474256143563}{,}{558458718976}$ (4)