Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
23 Views

random draw from normal distribution

Hello,

I want to draw random number from a normal distribution but my FORTRAN code does not work. Ireceive the following error: "unresolved external symbol vsrnggaussian referenced in function main".It is the first time that I am using the Math Kernel Library and I hope someone van help me with it. My code is as follows:

PROGRAM drawnormal

USE mkl_vsl

IMPLICIT NONE

integer status !Error / status

integer brng !Index of generator to initialize stream

integer method !Method = 0 in case of uniform distribution

integer dimen !Initial condition of the stream

TYPE (VSL_STREAM_STATE) stream !Random stream

integer, PARAMETER :: nr = 1000 !Number of values required (whatever you want)

real gauss(nr)

real mean, sigma

mean = 0.0

sigma = 1.0

!SOBEL

method = VSL_METHOD_SGAUSSIAN_ICDF !NB - are different alternatives, but I found this worked well

brng = VSL_BRNG_SOBOL

dimen = 1 ! <== different values may be needed depending on application

gauss = 0.0

status = vslnewstream( stream, brng, dimen ) !Create new stream (SOBOL in this case

status = vsrnggaussian( method, stream, nr, gauss, mean, sigma )

status = vsldeletestream( stream ) !Delete the stream

end

0 Kudos
2 Replies
Highlighted
Black Belt
23 Views

MKL is not used with every Fortran program. Therefore, you need to specify that you want the MKL linked in.

From the command line, use the -Qmkl (Windows) or -mkl (Linux/OSX) compiler option for a simple program such as the above.

In an IDE, do whatever is needed to link in the MKL as an additional library. See the MKL Link Line Advisor link at the top of this forum for further guidance.
0 Kudos
Highlighted
Moderator
23 Views

The similar problem has been discussed into this thread. Please see the reply #8 from Andrey Nikolaev. I hope it helps you.
--Gennady
0 Kudos