Sobol Sequence Generator

Overview

Sobol sequence generator (SSG) is one of the critical utilities needed by Monte-Carlo Simulation. The SSG utility can generate the sequence with a quasi-random distribution. The Sobol sequence is one of the most popular quasi-random sequence for its simplicity and efficiency in implementation. Specifically, sobol sequence in base b=2, it can be implemented efficiently using bit-vector operations to compute the radical inverse and there is only one point in the field [0,1) .

Algorithm

Low-Discrepancy (LD) Sequence is an indicator for how evenly a random sequence is distributed in sample space. The definition of discrepancy,

DN(P)=supBJ|A(B)Nλs(B)|

A digital radical inverse

Φb,C(i)=(b1bM)[C(a0(i)aM1(i))T]

where i=M1l=0al(i)bl, b is a non-negative integer. For each dimension of sobol sequence, it is comprised by a b=2 radical inversion, which have a individual matrix C inside.

Gray Code Implementation

Here, we give a brief outline of the implementation. With a pre-calculated matrix C, where the matrix-vector multiplications are performed in the finite field Zb see sobol reference. To generate the j-th component of the points in a Sobol sequence, we need to choose a primitive polynomial of some degree Sj in the field Z, where Z2=0,1, the equation is shown as follow:

xSj+a1,jxSj1+a2,jxSj2++aSj1,jx1+1

where the coefficients a1,j,a2,j,,aSj1,j are either 0 or 1. We define a sequence of positive integers {m1,j,m2,j,} by the recurrence relation:

mk,j:=2a1,jmk1,j22a2,jmk2,j 2Sj1aSj1,jmkSj+1,j2SjmkSj,jmkSj,j

where is the bit-by-bit exclusive-or operator. The initial values m1,j,m2,j,,mSj,j can be chosen freely provided that each mk,j,1kSj , is odd and less than 2k . The so-called direction numbers {ν1,j,ν2,j,} are defined by:

ν1,j:=mk,j2k

Then the xi,j element of the j-th dimension of the i-th point in a Sobol sequence, can be generated by:

xi,j:=i1ν1,ji2ν2,jνn,j

where ik is the k-th digit from the right-hand side when i is written in binary i=(i3i2i1)2. Here and elsewhere in this article, we use the notation ()2 to denote the binary representation of numbers. The formula above corresponds to the original implementation of Sobol. The (binary-reflected) Gray code of an integer i is defined as:

gray(i):=ii2=(i3i2i1)2(i4i3i2)2

It has the property that the binary representations of gray(i) and gray(i1) differs in only one position, namely, the index of the first 0 digit from the right in the binary representation of i1.

We generate the points of Sobol using

ˉxi,j:=gi,1ν1,jgi,2ν2,j

where gi,k is the k-th digit from the right of the Gray code of i in binary, i.e., gray(i)=(g3g2g1)2. Equivalently, since gray(i) and gray(i1) differ in one known position, we can generate the points recursively using:

ˉx0,j:=0,ˉxi,j:=ˉxi1,jˉxci1,j

where ci is the index of the first 0 digit from the right in the binary representation of i=(i3i2i1)2. We have c0=1,c1=2,c2=1,c3=3,c4=1,c5=2, etc.

With the implementation of Gray Code, we simply obtain the points in a different order, which still preserve their uniformity properties. It is because every block of 2m points for m=0,1, is the same as the original implementation. It is known that the two equations closely mentioned above can generate exactly the same sequence, and the former one allows one to start from any position in the sequence, while the later one is recursive and more computationally efficient. The reference is equation reference.

Sobol Workflow:

sobol sequence generator workflow
sobol sequence generator workflow

The initialization function will set addr=0 and read parameter list to initialize polynomial mSj,j. The parameter reference file new-joe-kuo-6.21201 is given by sobol reference mentioned above. The parameter field is shown as below:

bit field