random number generators

random number generators

Hi,
Why the first element of the vector is generated from the distribution with the mean value equal to 0.0. How should I correct this code:

void RNorm(int n ,float *x ,float mu=100.0f, float sigma=1.0f)
{
VSLStreamStatePtr stream;
vslNewStream( &stream, VSL_BRNG_MCG31, 777);
// vsRngGaussian( VSL_METHOD_SGAUSSIAN_BOXMULLER2, stream, 1, x, mu, sigma );  //if I use this line the result will be correct
vsRngGaussian( VSL_METHOD_SGAUSSIAN_BOXMULLER2, stream, n, x, mu, sigma );
vslDeleteStream( &stream );
}

Thanks,
Stan

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

here what i see with this generator when n == 11 elements:( mkl 11.0.update2) 

1.exe

mu == 100.000000

X[0] == 94.557526

X[1] == 100.209007
X[2] == 98.103668
X[3] == 101.462799
X[4] == 99.835510
X[5] == 100.047592
X[6] == 100.162888
X[7] == 100.772491
X[8] == 100.407875
X[9] == 98.523254
X[10] == 99.375008

Hello Stan,

Please, have a look at the paper which describes some aspects of initialization (seed'ing) of random number generators in Intel(R) Math Kernel Library, http://software.intel.com/en-us/articles/initializing-Intel-MKL-BRNGs/

Does it answer your question?

Thanks,

Andrey

Hello Andrey,

Thank you very much for your help. I have not read this document before but intuitively applied to the tips outlined in it.

With greetings,
Stan

Leave a Comment

Please sign in to add a comment. Not a member? Join today