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

Sobol Sequences / Gaussian

pdonahue
Beginner
627 Views
I'm trying to generate N-dimensional Gaussian Sobol sequences with mean 0 and std. dev of 1, but I'm noticing that the sample mean of the Nth dimension is quite off. Additionally, this column has no values that are >0, whereas all other columns seem to be properly distributed. Any ideas?

For example (check of return values removed for brevity):

const int METHOD=0, DIMENS=5, SAMPLES=100000;

VSLStreamStatePtr stream;
vslNewStream( &stream, VSL_BRNG_SOBOL, DIMENS );

double *MAT = new double[DIMENS*SAMPLES];
vdRngGaussian( METHOD, stream, DIMENS*SAMPLES, MAT, 0.0, 1.0 );

// if MAT is written to csv file, loaded into excel
// and sorted by column, it becomes apparent that
// the maximum value of the last column (5 in this case)
// is never >0. the mean of this column is also not close
// to 0 as one should expect(?). all other columns are
// distributed between -4 and 4, while column 5 is between
// 0 and 4.
0 Kudos
5 Replies
ttppo
Beginner
627 Views
Please try it:

#define SEED 1

.......................

double a=0.0,sigma=1.0;

.......................

/***** Initialize *****/
vslNewStream( &stream, VSL_BRNG_SOBOL, SEED );//Not vslNewStream( &stream, VSL_BRNG_SOBOL, DIMENS );

/***** Call RNG *****/
vdRngGaussian( METHOD, stream, DIMENS*SAMPLES, MAT, a, sigma );

.........................

.........................
/***** Deinitialize *****/
vslDeleteStream( &stream );
0 Kudos
ttppo
Beginner
627 Views
vslNewStream( &stream, VSL_BRNG_SOBOL, SEED );/*Not vslNewStream( &stream, VSL_BRNG_SOBOL, DIMENS );*/
0 Kudos
ttppo
Beginner
627 Views
vslNewStream( &stream, BRNG, SEED );
vdRngGaussian( METHOD, stream, N, r, a, sigma );
In the case of vdRngGaussian(...) called only once:
In fact, the "random" values are always fixed and not changed, if BRNG and SEED are not change.

But you can call vdRngGaussian() many times to generate the random values.
0 Kudos
ttppo
Beginner
627 Views
Or you can try:
#define SEED 7
0 Kudos
Andrey_N_Intel
Employee
627 Views
Box-Muller methodfor generation of one Gaussian random number uses a pair of uniform random variates. So, in order to obtain N samples of normally distributed random vectors of dimension DIM one needs to initialize Sobol quasi-random number generator with dimension (seed)2*DIM:
#define BRNG VSL_BRNG_SOBOL
#define SEED 10
#define METHOD 0
#define DIMENS 5
#define N 1000
...
vslNewStream( &stream, BRNG, SEED );
vdRngGaussian( METHOD, stream, DIMENS*N, r, 0.0, 1.0 );
vslDeleteStream( &stream );
...
Please, find additional information about methods of generation of Gaussian rundom numbers and quasi-random random generators implemented in VSL
0 Kudos
Reply