RandomTools[LinearCongruence] - Maple Programming Help

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

RandomTools[LinearCongruence]

 GenerateInteger
 Generate an integer using the Linear Congruence Generator

 Calling Sequence GenerateInteger( opt1, opt2, ... )

Parameters

 opt1, opt2, ... - (optional) argument of the form option=value where option is range

Description

 • The GenerateInteger command outputs a pseudo-random integer, generated using the LinearCongruence algorithm.
 • When generating a large number of random integers it is faster to create a generating procedure by calling NewGenerator than to call GenerateInteger multiple times.
 • The following optional arguments are supported. They are input as equations in any order.
 • range=integer..integer or integer
 If the value of the range argument is a range, then the integer will be chosen from that range.  If the value of the range argument is an integer, then the integer will be take from [0,range).  The default value is $1000000000000$.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}[\mathrm{LinearCongruence}]\right)$
 $\left[{\mathrm{GenerateInteger}}{,}{\mathrm{GetState}}{,}{\mathrm{NewGenerator}}{,}{\mathrm{SetState}}\right]$ (1)
 > $\mathrm{GenerateInteger}\left(\right)$
 ${427419669081}$ (2)
 > $\mathrm{GenerateInteger}\left(\right)$
 ${321110693270}$ (3)
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..10\right)$
 ${343633073697}{,}{474256143563}{,}{558458718976}{,}{746753830538}{,}{32062222085}{,}{722974121768}{,}{604305613921}{,}{745580037409}{,}{259811952655}{,}{310075487163}$ (4)
 > $\mathrm{GenerateInteger}\left(\mathrm{range}=1000..2000\right)$
 ${1350}$ (5)
 > $\mathrm{GenerateInteger}\left(\mathrm{range}=1000..2000\right)$
 ${1697}$ (6)
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\mathrm{range}=1000..2000\right),i=1..5\right)$
 ${1445}{,}{1791}{,}{1567}{,}{1736}{,}{1300}$ (7)
 > $\mathrm{seq}\left(\mathrm{Float}\left(\mathrm{GenerateInteger}\left(\mathrm{range}={10}^{10}\right),-10\right),i=1..5\right)$
 ${0.0624947349}{,}{0.1053530086}{,}{0.6486307198}{,}{0.5590763466}{,}{0.9392673709}$ (8)