Visible to Intel only — GUID: GUID-776A1C14-7111-4386-A29F-22AB55F6B553
Visible to Intel only — GUID: GUID-776A1C14-7111-4386-A29F-22AB55F6B553
Initializing a BRNG
To obtain a random number sequence from a given BRNG, you should assign initial, or seed values. The assigning procedure is called generator initialization. The C language function analogous with the initialization function is srand(seed) in stdlib.h. Different types of BRNGs require a different number of initial values. For example, the seed for MCG31m1 is an integral number within the range from 1 to 231-2, the initial values for MRG32k3a are a set of two triples of 32-bit digits, and the seed for MCG59 is an integer within the range from 1 to 259-1. Quasi-random generators require the dimension parameter on input. Thus, all BRNGs, including user-registered ones, require an individual initialization function.
To avoid limiting the versatility of the routines by providing individual initialization functions for each generator, VS offers an interface with a universal mechanism for generator initialization that encapsulates user-provided details of the initialization process. In line with this concept, VS offers two subroutines to initialize any BRNG (see the functions of random stream creation and initialization in the Random Streams section). These initialization functions can also be used to initialize user-provided functions.
One of the subroutines initializes a given BRNG using a single 32-bit initial value, which is called the seed. If the generator requires more than one 32-bit seed, VS initializes the remaining initial values on the basis of the original seed. Thus, generator R250, which requires 250 initial 32-bit values, is initialized using one 32-bit seed by the method described in [Kirk81].
The second subroutine is a generalization of the first one. It initializes a BRNG by passing an array of n 32-bit initial values. If the number of the initial values n is insufficient to initialize a given BRNG, the missing initial values are initialized by default values. If the number of the initial values n is excessive, the redundant values are ignored.
VS Notes document the initialization process for each library BRNG. For details, see Basic Random Generator Properties and Testing Results.
When calling initialization functions, you may ignore acceptability of the passed initial values for a given BRNG. If the passed seeds are unacceptable, the initialization procedure replaces them with acceptable values for a given type of BRNG. See Basic Random Generator Properties and Testing Results for details on acceptable initial values.
If you add a new BRNG to VS, you should implement an appropriate initialization function that supports the above mechanism of initial values passing, and, if required, apply the leapfrog and block-splitting techniques.