Notes for Intel® oneAPI Math Kernel Library Vector Statistics

ID 772987
Date 12/04/2020
Public
Document Table of Contents

SOBOL

This is a 32-bit Gray code-based quasi-random number generator:

NOTE:

The value c is the rightmost zero bit in n-1; xn is s-dimensional vector of 32-bit values. The s-dimensional vectors (calculated during random stream initialization) vi, i = 1,32 are called direction numbers. The vector un is the generator output normalized to the unit hypercube (0,1)s.

Bratley and Fox [Brat87] provide an implementation of the SOBOL quasi-random number generator. VS implementation allows generating SOBOL’s low-discrepancy sequences with the length of up to 232. This implementation also accepts registration of user-defined parameters (direction numbers and primitive polynomials) during the initialization, which permits obtaining quasi-random vectors of any dimension. If you do not supply user-defined parameters, the default values are used for generation of quasi-random vectors. The default dimension of quasi-random vectors can vary from 1 to 40 inclusive.

Real Implementation (Single and Double Precision)

The output vector is the sequence of the floating-point values u1, u2, ..., where elements u1, u2, ..., us correspond to theu1, us+1, us+2, ..., u2s correspond to the u2, and so on.

Integer Implementation

The output vector of 32-bit integers x1, x2, ..., where elements x1, x2, ..., xs correspond to the x1, xs+1, xs+2, ... , x2s correspond to the x2, and so on.

Stream Initialization by Function vslNewStream

SOBOL generates the stream and initializes it specifying the input 32-bit parameter seed (dimension dimen of a quasi-random vector):

  1. Assume dimen = seed

  2. If dimen < 1 or dimen > 40, assume dimen = 1.

Stream Initialization by Function vslNewStreamEx

SOBOL generates the stream and initializes it, specifying the array params[] of  n 32-bit integers to set the dimension dimen of a quasi-random vector as well as pass other generator related parameters. For example, initial direction numbers and primitive polynomials. Direction numbers can also be passed using the array. The general interface for passing stream initialization parameters of SOBOL via the params[] array has the following format:

Position in params[] 0 1 2
3...2+dimen
3+dimen
4+dimen...dimen*
		(maxdeg+1)+3
 
dimen
Parameter Class Indicators Initial Values Subclass Indicators Primitive polynomials Maximum degree of primitive polynomial, maxdeg Initial direction numbers

The dimension parameter params[0] is mandatory, and can be initialized as follows:

params[0] = dimen;

The other elements of params intended for passing additional user-supplied data are optional. For example, if they are not presented, then the default tables of direction numbers are used for generation of quasi-random vectors. VS default tables of direction numbers allow generating quasi-random sequences for dimensions up to 40.

If you want to generate quasi-random vectors of greater dimension or obtain another sequence you may register a set of your own primitive polynomials and/or a table of initial direction numbers. In order to do this, you need to set the Parameter Class Indicators field (params[1]) to VSL_USER_QRNG_INITIAL_VALUES:

params[1] = VSL_USER_QRNG_INITIAL_VALUES;

Further, you should specify in Initial Values Subclass Indicators field (params[2]) whether you want to supply primitive polynomials, initial direction numbers, or both, by setting corresponding indicators. In the example below both direction numbers and primitive polynomials indicators are set:

params[2] = VSL_USER_INIT_DIRECTION_NUMBERS | VSL_USER_PRIMITIVE_POLYMS;

If you want to provide just initial direction numbers, do it as follows:

params[2] = VSL_USER_INIT_DIRECTION_NUMBERS;

Similarly, you can indicate that only primitive polynomials are passed to the library:

params[2] = VSL_USER_PRIMITIVE_POLYMS;
NOTE:

For dimensions greater than 40, both the primitive polynomials and the table of initial direction numbers must be provided.

The remainder of the params array is used to pass primitive polynomials and/or initial direction numbers. Primitive polynomials are packed as unsigned integers, initial direction numbers for SOBOL are assumed to be a two-dimensional table. In the matrix i-th row corresponds to i-th dimension, and number of columns equals the maximum degree of primitive polynomials maxdeg. The number of polynomials (and the number of rows in the table) depends on the initialization mode for the first dimension. In the default initialization mode (see [Brat88] for details) it is enough to pass into the library dimen -1 primitive polynomials (correspondingly, the number of rows in the table of initial direction numbers also equals dimen -1). To override default initialization for the first dimension, set VSL_QRNG_OVERRIDE_1ST_DIM_INIT indicator in params[2]:

params[2] = params[2] | VSL_QRNG_OVERRIDE_1ST_DIM_INIT;

and pass a complete set of polynomials and/or initial direction numbers (dimen primitive polynomials and the table of initial direction numbers with dimen rows). If you pass just primitive polynomials or initial direction numbers for dimensions 1 ≤ s ≤ 40, the default initialization for the first dimension is always assumed (the number of polynomials and the number of rows in the table of initial direction numbers equals s-1).

If both arrays are passed to the generator you should organize data in correct order: first - polynomials, second - maximum degree of primitive polynomials and, finally, initial direction numbers as shown in the example below:

unsigned int uSobolIrredPoly[dimen] = {...};
unsigned int uSobolMInit[dimen][maxdeg] = {...};
...
params[0] = dimen;
params[1] = VSL_USER_QRNG_INITIAL_VALUES;
params[2] = VSL_USER_INIT_DIRECTION_NUMBERS|VSL_USER_PRIMITIVE_POLYMS;
params[2] = params[2] | VSL_QRNG_OVERRIDE_1ST_DIM_INIT;
 
for ( i = 0; i < dimen; i++ ) params[i+3] = uSobolIrredPoly[i];
params[3+dimen] = maxdeg;
k = 4+dimen;
for ( i = 0; i < dimen; i++ )
{
     for ( j = 0; j < maxdeg; j++ )
     {
          params[k++] = uSobolMInit[i][j];
     }
}

The following example illustrates replacement of the default initial values for SOBOL with user-provided values:

...
// dimen = 10
unsigned int uSobolMInit[dimen-1][maxdeg] = {...};
params[0] = dimen;
params[1] = VSL_USER_QRNG_INITIAL_VALUES;
params[2] = VSL_USER_INIT_DIRECTION_NUMBERS;
params[3] = maxdeg;
k = 4;
for ( i = 0; i < dimen-1; i++ )
{
     for ( j = 0; j < maxdeg; j++ )
     {
          params[k++] = uSobolMInit[i][j];
     }
       }

You can also calculate a table of direction numbers using your own initial direction numbers and primitive polynomials and pass this array to the generator. The interface for registration of the direction numbers is as follows:

Position in params[] 0 1 2
3...dimen*32+2
 
dimen
Parameter Class Indicators Initial Values Subclass Indicators Direction numbers

As earlier, the dimension parameter params[0] and Parameter Class Indicators field (params[1]) can be initialized as follows:

params[0] = dimen;
params[1] = VSL_USER_QRNG_INITIAL_VALUES;
Further, you need to initialize Initial Values Subclass Indicators field (params[2]):
params[2] = VSL_USER_DIRECTION_NUMBERS;

Direction numbers are assumed to be a dimen x 32 table of unsigned integers and can be passed to the generator in the following way:

unsigned int uSobolV[dimen][32] = {...};
params[0] = dimen;
params[1] = VSL_USER_QRNG_INITIAL_VALUES;
params[2] = VSL_USER_DIRECTION_NUMBERS;
k = 3;
for ( i = 0; i < dimen; i++ )
{
     for ( j = 0; j < 32; j++ )
     {
          params[k++] = uSobolV[i][j];
     }
}

In short, the SOBOL stream initialization is as follows:

  1. If n = 0, assume dimen = 1 and initialize the stream using the default table of primitive polynomials and initial direction numbers.

  2. If n = 1, dimen = params[0], initialize the stream using the default table of primitive polynomials and initial direction numbers; (if dimen < 1 or dimen > 40, assume dimen = 1).

  3. If n > 1, dimen = params[0]

    1. If dimen < 1, assume dimen = 1 and initialize the stream using the default table of primitive polynomials and initial direction numbers.

    2. If the externally defined parameters of the generator are packed incorrectly, initialize the stream using the default table of primitive polynomials and initial direction numbers; (if dimen > 40, assume dimen = 1).

    3. Initialize the SOBOL quasi-random stream by means of the user-defined primitive polynomials and initial direction numbers or direction numbers.

Subsequences Selection Methods

vslSkipAheadStream
Supported
vslSkipAheadStreamEx
Not supported
vslLeapfrogStream
Supported
NOTE:
  1. The skip-ahead method skips individual components of quasi-random vectors rather than whole s-dimensional vectors. Hence, to skip N s-dimensional quasi-random vectors, call vslSkipAheadStream subroutine with parameter nskip equal to the Nxs.

  2. The leapfrog method works with individual components of quasi-random vectors rather than with s-dimensional vectors. In addition, its functionality allows picking out a fixed quasi-random component only. In other words, nstreams parameter should be equal to the predefined constant VSL_QRNG_LEAPFROG_COMPONENTS, and k parameter should indicate the index of a component of s-dimensional quasi-random vectors to be picked out (0 ≤ k < s).

Generator Period

Dimensions

is the default set of dimensions; user-defined dimensions are accepted.