 RandomTools[LinearCongruence] - Maple Programming Help

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

RandomTools[LinearCongruence]

 SetState
 Set the internal state of the Linear Congruence 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 Linear Congruence pseudo-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
 The state argument specifies the data used to set the state of the generator.  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{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}=1234567\right)$
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${218604127385}{,}{665262624842}{,}{52899550817}{,}{984396582721}{,}{705317627386}$ (4)
 > $\mathrm{SetState}\left(\mathrm{state}=1234567\right)$
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${218604127385}{,}{665262624842}{,}{52899550817}{,}{984396582721}{,}{705317627386}$ (5)
 > $\mathrm{SetState}\left(\mathrm{state}=s\right)$
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..5\right)$
 ${427419669081}{,}{321110693270}{,}{343633073697}{,}{474256143563}{,}{558458718976}$ (6)