Overview of the RandomTools[QuadraticCongruence] Subpackage - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

Overview of the RandomTools[QuadraticCongruence] Subpackage

 

Calling Sequence

Description

List of RandomTools[QuadraticCongruence] Subpackage Commands

Examples

Calling Sequence

RandomTools[QuadraticCongruence][function](arguments)

function(arguments)

Description

• 

The RandomTools[QuadraticCongruence] subpackage contains functions for creating pseudo-random number generators using the Quadratic Congruence algorithm.  The integers x1,x2, ... are generated using the quadratic recurrence

xk+1=xk2modn

  

where n is a product of two primes and x0, the seed, may be specified by the user.  They use the least significant bits of the x's to form the random numbers.

• 

The Quadratic Congruential Generator creates generators using primes of length either 10, 12, 15 or 16 digits. These generators can be used for every day scientific applications.

• 

Each command in the RandomTools[QuadraticCongruence] subpackage can be accessed by using either the long form or the short form of the command name in the command calling sequence.

  

As the underlying implementation of the RandomTools[QuadraticCongruence] subpackage is a module, it is also possible to use the form RandomTools:-QuadraticCongruence:-command to access a command from the package. For more information, see Module Members.

List of RandomTools[QuadraticCongruence] Subpackage Commands

NewGenerator

 

 

 

  

To display the help page for a particular QuadraticCongruence command, see Getting Help with a Command in a Package.

Examples

withRandomTools[QuadraticCongruence]

NewGenerator

(1)

We first create a random number generator for generating random numbers on the range 1..6 and generate two random numbers.

dieNewGeneratorrange=1..6

die:=procx:=iremx^2,n;iremx,6+1end proc

(2)

die

6

(3)

die

2

(4)

Now we roll the die 10 times.

seqdie,i=1..10

2,5,5,1,3,2,5,4,4,5

(5)

Now we create a 10 decimal digit random number generator. To form uniformly distributed floating point random numbers with 10 digits of precision on [0,1) we use the command Floatm,e which forms the floating point number m10e.

RNewGeneratorrange=0..1010

R:=proclocaly&semi;x:=iremx&Hat;2&comma;n&semi;y:=iremx&comma;10000000000&semi;whiley<10000000001dox:=iremx&Hat;2&comma;n&semi;y:=10000000000&ast;y&plus;iremx&comma;10000000000end do&semi;iremy&comma;10000000001end proc

(6)

mR

m:=742625902

(7)

e10

e:=10

(8)

Floatm&comma;e

0.0742625902

(9)

seqFloatR&comma;e&comma;i&equals;1..5

0.9305361902&comma;0.0805966638&comma;0.4297131736&comma;0.5949740789&comma;0.0017230061

(10)

For further options see help page for the NewGenerator command.

See Also

rand

RandomTools

RandomTools[BlumBlumShub]

RandomTools[LinearCongruence]

RandomTools[MersenneTwister]

UsingPackages

with

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam