|
NAG[g05kac] NAG[nag_rngs_basic] - Pseudo-random real numbers, uniform distribution over (0,1), seeds and generator number passed explicitly
|
|
Calling Sequence
g05kac(igen, iseed)
nag_rngs_basic(. . .)
Parameters
|
iseed - Vector(1.. , datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On entry: contains values which define the current state of the selected generator.
|
|
On exit: contains updated values defining the new state of the selected generator.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_rngs_basic (g05kac) returns a pseudo-random number taken from a uniform distribution between 0 and 1.
|
|
Description
|
|
nag_rngs_basic (g05kac) returns the next pseudo-random number from a uniform generator.
The particular generator used to generate random numbers is selected by the value set for the input argument igen. Consult the g05 Chapter Introduction for details of the algorithms that can be used.
The current state of the chosen generator is saved in the integer array iseed which should not be altered between successive calls. Initial states are set or re-initialized by a call to g05kbc (nag_rngs_init_repeatable) (for a repeatable sequence if computed sequentially) or g05kcc (nag_rngs_init_nonrepeatable) (for a non-repeatable sequence).
g05lgc (nag_rngs_uniform) may be used to generate a vector of pseudo-random numbers which, if computed sequentially using the same generator, are exactly the same as successive values of this function. On many machines g05lgc (nag_rngs_uniform) is likely to be much faster.
|
|
Error Indicators and Warnings
|
|
None.
|
|
Further Comments
|
|
The generator with the smallest period that can be selected is the basic generator. The period of the basic generator is .
Its performance has been analysed by the Spectral Test, see Section .4 of Knuth (1981), yielding the following results in the notation of Knuth (1981).
The right-hand column gives an upper bound for the values of attainable by any multiplicative congruential generator working modulo .
An informal interpretation of the quantities is that consecutive -tuples are statistically uncorrelated to an accuracy of . This is a theoretical result; in practice the degree of randomness is usually much greater than the above figures might support. More details are given in Knuth (1981), and in the references cited therein.
Note that the achievable accuracy drops rapidly as the number of dimensions increases. This is a property of all multiplicative congruential generators and is the reason why very long periods are needed even for samples of only a few random numbers.
|
|
|
Examples
|
|
>
|
igen := 1:
iseed := Vector([1762543, 9324783, 42344, 742355], datatype=integer[kernelopts('wordsize')/8]):
NAG:-g05kac(igen, iseed);
|
|
|
Download Help Document
Was this information helpful?