GenerateInteger - Maple Help

RandomTools[MersenneTwister]

 GenerateInteger
 Generate an integer using the Mersenne Twister 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 MersenneTwister algorithm.
 • When generating a large number of random integers it is faster to create a generating procedure by calling NewGenerator than to call GenerateInteger.
 • 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 is chosen from that range.  If the value of the range argument is an integer, then the integer is chosen from the range 0..value-1.  The default value is $1000000000000$.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\left[\mathrm{MersenneTwister}\right]\right)$
 $\left[{\mathrm{GenerateData}}{,}{\mathrm{GenerateFloat}}{,}{\mathrm{GenerateFloat64}}{,}{\mathrm{GenerateInteger}}{,}{\mathrm{GenerateInteger32}}{,}{\mathrm{GenerateUnsignedInt32}}{,}{\mathrm{GetState}}{,}{\mathrm{NewGenerator}}{,}{\mathrm{SetState}}\right]$ (1)
 > $\mathrm{GenerateInteger}\left(\right)$
 ${395718860534}$ (2)
 > $\mathrm{GenerateInteger}\left(\right)$
 ${193139816415}$ (3)
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\right),i=1..10\right)$
 ${22424170465}{,}{800187484459}{,}{427552056869}{,}{842622684442}{,}{412286285840}{,}{996417214180}{,}{386408307450}{,}{694607189265}{,}{773012980023}{,}{730616292946}$ (4)
 > $\mathrm{GenerateInteger}\left(\mathrm{range}=1000..2000\right)$
 ${1024}$ (5)
 > $\mathrm{GenerateInteger}\left(\mathrm{range}=1000..2000\right)$
 ${1601}$ (6)
 > $\mathrm{seq}\left(\mathrm{GenerateInteger}\left(\mathrm{range}=1000..2000\right),i=1..5\right)$
 ${1604}{,}{1827}{,}{1476}{,}{1397}{,}{1049}$ (7)
 > $\mathrm{seq}\left(\mathrm{Float}\left(\mathrm{GenerateInteger}\left(\mathrm{range}={10}^{10}\right),-10\right),i=1..5\right)$
 ${0.8415955883}{,}{0.2816384844}{,}{0.8743315087}{,}{0.3646982597}{,}{0.4011470445}$ (8)