VSL_BRNG_MT19937 bug?

VSL_BRNG_MT19937 bug?

I'm using VSL to generate a stream of Gaussian distributed random numbers. As basic random number generator I'm using the Mersenne Twister method (VSL_BRNG_MT19937) together with Box Muller (VSL_METHOD_DGAUSSIAN_BOXMULLER2), at certain point of the simulation it sorts out a NaN in the stream. I did and attached a small code to test and by the 19468th stream generated it appears one (and only one) element of the stream is NaN. It seems it is a problem of the BRNG as it seems to work fine with VSL_BRNG_MCG31. I tried with other seeds and this still happening, but in this case you have to wait longer for the bug to happen.

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

Thank you for your question and testcase.
You do not indicate version of the library you use (presumably, v8.0). Generation of multivariate normal distribution is based on linear transformation of vector with independent standard Gaussian components. Gaussian variables are obtained, in particular, using BoxMuller2 method:x1 = sqrt(-2*ln(u1))*sin(2*pi*u2)
x2 = sqrt(-2*ln(u1))*cos(2*pi*u2),where (u1,u2) is pair of independend uniform variates.Some of VSL basic random number generators (including Mersenne Twister) can produce zero, whereas the others (e.g., MCG31 or MCG59) do not.
Random zero results in generation of infinities and, as consequence, in NANs in multivariate Gaussian generator.
This feature of the distribution generators is documented in MKL 8.0 Manual (please, see footnote in Advanced Service Routines section of the Statistical Functions chapter).
As temporal workaround you may check generated random sequence and remove bad elements. You also may use basic random number generators which do not produce zero (for example, MCG59). This issue is fixed in MKL 8.1.1 and MKL 9.0 Beta.

Ok! Thanks for that!. I'm actually using version 9.1 of ifort and 8.1 of mkl.

Leave a Comment

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