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

Generate Sobol Sequence

velvia
初學者
1,276 檢視

Hi,

I would like to generate numbers from the Sobol sequence in dimension n (with n < 40). The MKL has a Sobol sequence generator, but reading the documentation only gives me headaches. I gave up when I saw (https://software.intel.com/en-us/node/521851) that the directory that should contain examples for the VSL is only available on my installation.

Is there anyone who could give me a simple file that generates the Sobol sequence from the MKL ?

Thanks for your help.

 

0 積分
1 解決方案
Andrey_N_Intel
1,276 檢視

Hello,

You can find the short example that demonstrates the use of the Intel(R) MKL Sobol QRNG in the VSL notes, https://software.intel.com/en-us/node/498121. Additionally, I attach C example that shows how to generate Sobol random vectors of dimension 20. Please, let us know, if you have any questions on Intel(R) MKL RNGs, and we will gladly help.

Thanks,

Andrey

在原始文章中檢視解決方案

2 回應
Andrey_N_Intel
1,277 檢視

Hello,

You can find the short example that demonstrates the use of the Intel(R) MKL Sobol QRNG in the VSL notes, https://software.intel.com/en-us/node/498121. Additionally, I attach C example that shows how to generate Sobol random vectors of dimension 20. Please, let us know, if you have any questions on Intel(R) MKL RNGs, and we will gladly help.

Thanks,

Andrey

Andrey_N_Intel
1,276 檢視

I additionally include the code of the example here

#include <stdio.h>
#include "mkl.h"



/* Dimension of vectors to generate */
#define DM 20

#define NN  10

/* Size of buffer for quasi-random sequence */
#define N   1000*DM

/* Buffer for quasi-random sequence */
double rt;

int main()
{
    VSLStreamStatePtr stream;

    MKL_INT brng;
    int dim;
    int errcode;
    double a, b;
    int i, k;


    /***** Initialize *****/
    brng = VSL_BRNG_SOBOL;
    a = 0.0;
    b = 1.0;
    dim = DM;

    /* Initialize */
    errcode = vslNewStream( &stream, brng, (MKL_INT)dim );

    /***** Call RNG *****/
    errcode = vdRngUniform( VSL_RNG_METHOD_UNIFORM_STD, stream, N, rt, a, b );

    /***** Printing results *****/
    printf("Sobol sequence :\n");
    printf("--------------------------------------------------\n\n");
    printf("Parameters:\n");
    printf("    a=%.4f\n",a);
    printf("    b=%.4f\n\n",b);

    k = 12;
    printf("Results: %d component of quasi-random sequence (first %d of %d):\n", k, NN, N/dim);

    for(i=0;i<NN;i++) {
        printf("%.4f ",rt[k+i*dim]);
    }
    printf("\n\n");

    /***** Deinitialize *****/
    errcode = vslDeleteStream( &stream );

    return 0;
}
回覆