NAG Library Function Document
nag_rand_init_nonrepeatable (g05kgc) initializes the selected base generator to generate a non-repeatable sequence of variates. The base generator can then be used by the group of pseudorandom number functions (see g05khc
) and the quasi-random scrambled sequence initialization function, nag_quasi_init_scrambled (g05ync)
nag_rand_init_nonrepeatable (g05kgc) selects a base generator through the input value of the arguments genid
, and then initializes it based on the values taken from the real-time clock, resulting in the same base generator yielding different sequences of random numbers each time the calling program is run. It should be noted that there is no guarantee of statistical properties between sequences, only within sequences.
A definition of some of the terms used in this description, along with details of the various base generators can be found in the g05 Chapter Introduction
L'Ecuyer P and Simard R (2002) TestU01: a software library in ANSI C for empirical testing of random number generators
Departement d'Informatique et de Recherche Operationnelle, Universite de Montreal http://www.iro.umontreal.ca/~lecuyer
Maclaren N M (1989) The generation of multiple independent sequences of pseudorandom numbers Appl. Statist. 38 351–359
Matsumoto M and Nishimura T (1998) Mersenne twister: a 623-dimensionally equidistributed uniform pseudorandom number generator ACM Transactions on Modelling and Computer Simulations
Wichmann B A and Hill I D (2006) Generating good pseudo-random numbers Computational Statistics and Data Analysis 51 1614–1622
Wikramaratna R S (1989) ACORN - a new method for generating sequences of uniformly distributed pseudo-random numbers Journal of Computational Physics 83 16–31
genid – Nag_BaseRNGInput
: must contain the type of base generator to use.
- NAG basic generator.
- Wichmann Hill I generator.
- Mersenne Twister.
- Wichmann Hill II generator.
- ACORN generator.
- L'Ecuyer MRG32k3a generator.
See the g05 Chapter Introduction
for details of each of the base generators.
, , , , or .
subid – IntegerInput
indicates which of the
sub-generators to use. In this case, the
sub-generator is used.
indicates the values of
to use, where
is the order of the generator, and
controls the size of the modulus,
, the default values of
are used, otherwise values for
are calculated from the formula,
the range of the generator is set to
, otherwise the range is set to
; in this case the sequence is identical to the implementation of MRG32k3a in TestU01 (see L'Ecuyer and Simard (2002)
) for identical seeds.
For all other values of genid
is not referenced.
state[lstate] – IntegerCommunication Array
: contains information on the selected base generator and its current state. If
may be NULL
lstate – Integer *Input/Output
: the dimension of the state
array, or a value
. If the Mersenne Twister (
) is being used and the skip ahead function nag_rand_skip_ahead (g05kjc)
or nag_rand_skip_ahead_power2 (g05kkc)
will be called subsequently, then you must ensure that
on entry, then the required length of the state
array for the chosen base generator, otherwise lstate
is unchanged. When
(Mersenne Twister) a value of
is returned, allowing for the skip ahead function to be subsequently called. In all other cases the minimum length, as documented in the constraints below, is returned.
- if , ;
- if , ;
- if , ;
- if , ;
- if , , where and are defined by subid;
- if , ;
- otherwise .
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
Dynamic memory allocation failed.
On entry, argument had an illegal value.
On entry, .
Constraint: or .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG
8 Parallelism and Performance
This example prints the first five pseudorandom real numbers from a uniform distribution between
, generated by nag_rand_basic (g05sac)
after initialization by nag_rand_init_nonrepeatable (g05kgc).
10.1 Program Text
Program Text (g05kgce.c)
10.2 Program Data
10.3 Program Results
Program Results (g05kgce.r)