Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

Random Number Generator

$
0
0

Hello,

 

I am trying to generate a vector of random numbers using the following code. However, every time I execute the code, the output vector is the same as previous run! Can you please help? Thank you in advance. - Afshin

 

    int N = 30;
    double r[N];
    VSLStreamStatePtr stream;
    int errcode;
    double a=0,sigma=0.5;
   
    /***** Initialize *****/
    errcode = vslNewStream( &stream, VSL_BRNG_MT2203, 10000 );
    printf("err = %i\n",errcode);
    /***** Call RNG *****/
    errcode = vdRngGaussian( VSL_RNG_METHOD_GAUSSIAN_BOXMULLER, stream, N, r, a, sigma );
    printf("err = %i\n",errcode);
    vslDeleteStream(&stream);
 
    for (i=0; i<N; i++){
        printf("r = %f\n",r[i]);
    }

 


Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>