nag_rngs_basic (g05kac) returns a pseudorandom number taken from a uniform distribution between and .
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
nag_rngs_init_repeatable (g05kbc) (for a repeatable sequence if computed sequentially) or
nag_rngs_init_nonrepeatable (g05kcc) (for a non-repeatable sequence).
nag_rngs_uniform (g05lgc) may be used to generate a vector of
pseudorandom numbers which, if computed sequentially using the same generator, are exactly the same as
successive values of this function. On many machines
nag_rngs_uniform (g05lgc) is likely to be much faster.
None.
Not applicable.
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 3.3.4 of
Knuth (1981), yielding the following results in the notation of
Knuth (1981).
|
|
Upper bound for |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
This example prints the first five pseudorandom numbers from a uniform distribution between
and
, generated by nag_rngs_basic (g05kac) after initialization by
nag_rngs_init_repeatable (g05kbc).
None.