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

MKL - F95 syntax for random number generators

davidspurr
Beginner
593 Views
I decided to test MKL for quasi-random number generation, but I am struggling with the required syntax for even the most basic functions (despite > 3000 pp of the Ref Manual & ~40 yrs since starting on Fortran programming). Some actual illustrative examples would help immensely.

Starting with the most basic - say a uniform series of 1000 numbers ("ran_num") in the range 0.0 - 1.0 using the SOBOL generator. The syntax appears to be:

real ran_num(1000)
status = vsrnguniform( method, stream, 1000, ran_num, 0.0, 1.0 )


1: method

On p.2361 it is stated that "method is the number specifying the method of generation". Number? Nowhere can I find a table of these "numbers".

In the 3rd sentence of the same paragraph, it is stated that "See the next page for method name structure definition" !!!

Number? .. name? .. structure? Which is it?

A few pages further on, the syntax required for the input parameters is given; eg. on p.2403 for "random numbers with uniform distribution", "method" is defined as:
Type "INTEGER", then under
Description
"the specific values are as follows: VSL_METHOD_SUNIFORM_STD, ... ".
Since when has the value "VSL_METHOD_SUNIFORM_STD" been an integer?

Just how am I supposed to specify "method":
status = vsrnguniform( VSL_METHOD_SUNIFORM_STD, stream, 1000, ran_num, 0.0, 1.0 )
status = vsrnguniform( 'VSL_METHOD_SUNIFORM_STD', stream, 1000, ran_num, 0.0, 1.0 ) ! or
status = vsrnguniform( n, stream, 1000, ran_num, 0.0, 1.0 )
where "n" is a number somehow corresponding to "VSL_METHOD_SUNIFORM_STD"?

If so, where do I find the numbers required to specify "VSL_METHOD_SUNIFORM_STD"?

Besides, all that "method" seems to be achieving is a REPITITION of the fact that I want a uniform distribution.  ; That is already defined by the name of function itself (ie. "vsrnguniform").

.... this post has become too long & too frustrating !!!

I had similar uncertainties in regard to "stream" and "status" - will not procede further with this post because I have now located a sample code provided to another user which hopefully will help.

Needless to say this has been a very frustrating & time-wasting exercise. I spent hours searching the more than 3,000 page Reference Manual trying to clarify the usage without avail. All this could be VERY simply be avoided by including small code samples illustrating usage in the Reference Manual (eg including variable declarations & initialisations etc).


######################

Hmm. Have now looked through the example provided to the other user.

First it is using subroutines rather than functions. The default is now the function-style interface, so some of the syntax will be different.

Second, I certainly had not guessed the required order of statements from the descriptions in the Ref manual; eg. the order of presentation is "Transformation routines" (eg vsrnguniform) then "Service routines" (eg vslnewstream).

Never was clear that vslnewstream needs to be "called" before vsrnguniform. Again, example code snippets would help.

Third, it contains the following code:

include 'mkl_vsl.fi'
.....
integer brng
.....
brng=VSL_BRNG_SOBOL

which only makes sense if VSL_BRNG_SOBOL is a variable declared & initialised in 'mkl_vsl.fi'.
So that is what was meant by "name structure definition" - the name of a variable (a couple of extra words would certainly have greatly helped).

Referring to the "values" of an INTEGER as being VSL_METHOD_SUNIFORM_STD still does not make sense to me.

There are also the following two lines of code:

c Method = 0 in case of uniform distribution
integer method

I searched & searched but never found anything in the Manual indicating that "Method = 0 in case of uniform distribution" (Nor any other numerical values for Method). Then again, maybe I missed something on one of the 3,250 pages. But they are certainly not given in Ch10 which is the relevant chapter for the Statistical Functions.

So where are these values specified?

Enough!







0 Kudos
1 Reply
Andrey_N_Intel
Employee
593 Views

Thank you for your feedback on MKLVSL documentation. We will have a closer look on how to address your concerns. We would appreciate if you report your concerns via Premier Support. Fortran examples which demonstrate use of VSL functions are available in examplesvslfsource sub-directory of MKL directory. Please let us know in case you have other concerns/suggestions.

0 Kudos
Reply