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

Estimated variance of random numbers w.r.t. vRngGaussianMV



I use the outdated MKL 10.2 to generated multi-variate normal distributed random numbers. My results are not what I expect, perhaps I have misinterpreted the arguments or there is a bug in the MKL release I use. I hope someone has an idea:

I applied vRngGaussianMV to dimension 2, 50.000 2-dimensional vectorsof random numbers are generated. Moverover VSL_RNG_METHOD_GAUSSIANMV_ICDF is used as well as the VSL_MATRIX_STORAGE_FULL storage type, mean vector is {0, 1.5}. The Fortran interface of vRngGaussianMV is used, the argument t with the Pseuo-Squareroot of the covariance matrix is set to {5, 0, 2, 4}. If understand it correctly, the matrix argument is interpreted as

T^t =  (5 2 \\ 0 4)

I calculate the estimated mean and variance of the first and second component of the outcome, i.e. the projection of each second random number starting at the first, second random number of argument r respectively.I use MT19937 as well as for example MCG59 Random Number Generator with seed = 1234.

Results w.r.t MT19937

projection_0:  estimation mean = -0.0001 \approx 0, estimated variance = 24,9984 \approx 25

projection_1: estimated mean=1,49958 \approx 1.5, estimated variance = 31.701

Results w.r.t. MCG59

projection_0: estimated mean = -0.012 \approx 0, estimated variance = 24.87 \approx 25

projection_1: estimated mean = 1.492 \approx 1.5, estimated variance = 19.983

The result of the MCG59 Random Number is reasonable, because the variance of the second projection should be 2² + 4² = 20. Even if I increase the number of realisiations nothing changed. I played around with the seed but I did not get reasonable results for the Mersenner Twister (MT19937) Random Number Generator. Any ideas why the values are that far away? As I said I use MKL 10.2.

Kind regards

Markus Wendt

0 Kudos
3 Replies
Black Belt

the Pseuo-Squareroot of the covariance matrix is set to {5, 0, 2, 4}.
The covariance matrix should be symmetric (and positive semi-definite). The matrix that you used is not symmetric, unless it was intended to be just the upper triangular part, and I do not know what the MKL routines will turn out when invoked with improper input. We need details of the call to the MKL routine; in particular, the storage scheme parameter, if not properly chosen, can certainly cause errors.

0 Kudos

Hi Markus,

In order to clarify the reasons behind  the results you see with multivariate Gaussian RNG in MKL 10.2 I developed fortran testcase which is based on VSL vdrnggaussianmv.f example available at vslf/source directory of MKL folder. Please, review it and let me know if it reproduces your case or suggest any changes.

I use the build line below to buld the testcase:

gfortran -m64  -I$MKLROOT/include vdrnggaussianmv.f  -Wl,--start-group  $MKLROOT/lib/em64t/libmkl_intel_lp64.a $MKLROOT/lib/em64t/libmkl_sequential.a $MKLROOT/lib/em64t/libmkl_core.a -Wl,--end-group -lpthread -lm

MKLROOT points at Intel(R) MKL 10.2 Update 4.


0 Kudos

Hi Andrey,

thanks a lot! Your code works fine. I told only half of the story, I wrote an .net wrapper for the MKL Library and use the Fortran interface for vRngGaussianMV. The problem was in the calling of vslnewstream, my 'brng' argument was set to 6291456 instead to 8388608[=VSL_BRNG_MT19937] which should be an invalid argument with unpredictable results.

The constant VSL_RNG_METHOD_GAUSSIANMV_ICDFin your code is equal to 0, in '' I did not found this constant, only a similar constant with value 2. If I use method = 0 my .net code produces the same results as your Fortran implementation.



0 Kudos