Next: , Up: Base Generators


6.1.1 Initialization of the Base Generators

A random number generator must be initialized before use. Three routines are supplied within the ACML for this purpose: DRANDINITIALIZE, DRANDINITIALIZEBBS and DRANDINITIALIZEUSER (see DRANDINITIALIZE, DRANDINITIALIZEBBS and DRANDINITIALIZEUSER, respectively). Of these, DRANDINITIALIZE is used to initialize all of the supplied base generators, DRANDINITIALIZEBBS supplies an alternative interface to DRANDINITIALIZE for the Blum-Blum-Shub generator, and DRANDINITIALIZEUSER allows the user to register and initialize their own base generator.

Both double and single precision versions of all RNG routines are supplied. Double precision names are prefixed by DRAND, and single precision by SRAND. Note that if a generator has been initialized using the relevant double precision routine, then the double precision versions of the distribution generators must also be used, and vice versa. This even applies to generators with no double or single precision parameters; for example, a call of DRANDDISCRETEUNIFORM must be preceded by a call to one of the double precision initializers (typically DRANDINITIALIZE).

No utilities for saving, retrieving or copying the current state of a generator have been provided. All of the information on the current state of a generator (or stream, if multiple streams are being used) is stored in the integer array STATE and as such this array can be treated as any other integer array, allowing for easy copying, restoring etc.

The statistical properties of a sequence of random numbers are only guaranteed within the sequence, and not between sequences provided by the same generator. Therefore it is likely that repeated initialization will render the numbers obtained less, rather than more, independent. In most cases there should only be a single call to one of the initialization routines, per application, and this call must be made before any variates are generated. One example of where multiple initialization may be required is briefly touched upon in Multiple Streams.

In order to initialize the Blum-Blum-Shub generator a number of additional parameters, as well as an initial state (seed), are required. Although this generator can be initialized through the DRANDINITIALIZE routine it is recommended that the DRANDINITIALIZEBBS routine is used instead.