Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Wichmann-Hill BRNG Seeding

melknin
Beginner
261 Views
We are porting our application to various platforms where Intel MKL isn't available and using the NAG C Library to fill in. We noticed that both packages offer the Wichmann-Hill pseudorandom number generator, and we would like to make it so that given the same seed, the same output will be produced. However, according to the description and implementation of Wichmann-Hill on NAG, four seeds and a generator ID must be provided to initialize the stream while the VSL library uses a single seed when initializing. Thus, we can't see any immediate way of analogously seeding the two streams.



Is there a way in which, given a seed, we may produce the same output so that we can get consistent results across platforms?



Thanks
0 Kudos
1 Reply
Andrey_N_Intel
Employee
261 Views
Thank you for your question.
Wichmann-Hill pseudorandom number generator requires 4 seeds for its initialization. To pass them into the library you need to use vslNewStreamEx routine. Example below demonstrates how it works:
...
#define BRNG VSL_BRNG_WH
#define METHOD 0
#define N 1000
#define NSEED 4
...
int main()
{
unsigned int seed[NSEED];
double r;
VSLStreamStatePtr stream;
seed[0] = 123;
seed[1] = 124;
seed[2] = 125;
seed[3] = 126;
...
vslNewStreamEx( &stream, BRNG, NSEED, seed );
vdRngUniform( METHOD, stream, N, r, 0.0, 1.0 );
vslDeleteStream( &stream );
...
return 0;
}
If for some reasons number of seeds passed into the library is less than 4 (for example, when vslNewStream function is used for the initialization of the stream) the remaining seeds are set to thedefault values. More details about initialization of the Wichmann-Hill generator can be found in the Vslnotes.pdf (http://www.intel.com/software/products/mkl/docs/vslnotes.pdf),
section Testing of Basic Random Number Generators->Basic Random Generator Properties and Testing Results->WH.
0 Kudos
Reply