Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

random number generators

stansy
Beginner
686 Views

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

0 Kudos
3 Replies
Gennady_F_Intel
Moderator
686 Views

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

0 Kudos
Andrey_N_Intel
Employee
686 Views

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

0 Kudos
stansy
Beginner
686 Views

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

0 Kudos
Reply