Procedure: Generating a Sobol’s Sequence

Description and Background

The numbers in a Sobol’s sequence are generated directly as binary fractions of length \(w\) bits. These numbers are created from a special set of \(w\) binary fractions \(V_i\) called direction numbers. In Sobol’s original method, the j-th number \(X_j\) is generated by the operation XOR among those direction numbers \(V_i\) such that the i-th bit of \(j\) is not zero, see comments below. See DiscSobol for additional discussion.

Detailed description of the procedure

The \(i\)-th number in Sobol’s sequence is

\[x_i=\bigoplus_{j=1}^\infty b_j(i)v_j,\]

where \(b_j(i)\) is the \(j\)-th digit of the binary expansion of \(i\); \(v_j\) is the \(j\)-th direction number and \(\oplus\) is the binary (bitwise) XOR operation. The number \(b_j(i)\) is a bit and thus it only takes values \(0\) or \(1\), i.e. for an integer \(i\) we have its binary expansion

\[i=\sum_{j=1}^\infty b_j(i)2^{j-1}.\]

As for any finite number \(i\), its binary expansion has a finite number of non-zero digits, the Sobol’s number is computed with a XOR sum of a finite number of direction numbers and thus no convergence properties are needed in the above equations.

An important element in Sobol’s sequence are the direction numbers. The direction numbers are binary (dyadic) fractions \(v_j\in(0,1)\) and the resulting Sobol’s number is also a binary fraction \(x_i\in(0,1)\). The direction numbers are represented as

\[v_j=\frac{m_j}{2^j}\]

where \(m_j\) takes integer values, \(1<m_j<2^j\), i.e. the direction number \(v_j\) is a shift of the binary digits in \(m_j\). The direction numbers are computed by the recursive relation

\[m_j=\left(\bigoplus_{k=1}^d2^ka_km_{j-k} \right)\bigoplus m_{j-d},\]

where the initial values \(m_1,\ldots,m_d\) are odd integers and the numbers \(a_0,a_1,\ldots,a_d\) are given by the coefficients of \(p_d(x)\), a primitive polynomial of degree \(d\) in \({Z}_2,\) which is written as

\[p_d(x)=\sum_{k=0}^da_kx^{d-k}.\]

Recall that a primitive polynomial is a polynomial that cannot be represented as the product of two polynomials of lower degree. Primitive polynomials are available in tables in the literature, see Press et al. (1994). For a primitive polynomial, the numbers \(a_0\) and \(a_d\) take the value one by definition, and \(a_0\) is not used in the computations.

Running example

In what follows, the subindex \(_{\textbf{2}}\) refers to binary numbers, everywhere else usual representation (base ten) is assumed.

Take the primitive polynomial \(p_3(x)=x^3+x+1\), and thus \(d=3\) and \((a_0,a_1,a_2,a_3)=(1,0,1,1)\). The recurrence relation for the direction numbers is

\[\begin{split}\begin{array}{rcl}m_j&=2a_1m_{j-1}\oplus 4a_2m_{j-2}\oplus 8a_3m_{j-3}\oplus m_{j-3}\\&=4m_{j-2}\oplus 8m_{j-3}\oplus m_{j-3} \\ \end{array}\end{split}\]

Using a different primitive polynomial will give a different recurrence relation. To iterate the recurrence relation, initial odd values \(m_1,m_2,m_3\) are needed. Take \(m_1=1,m_2=3,m_3=7.\)

Now we compute a few extra numbers \(m_j\). We have

\[\begin{split}\begin{array}{rcl}m_4&=4(3)\oplus 8(1)\oplus 1=12\oplus 8\oplus 1 \\ &=1100_{\textbf{2}}\oplus 1000_{\textbf{2}}\oplus 1_{\textbf{2}}=101_{\textbf{2}}=5 \end{array}\end{split}\]

and

\[m_5=28\oplus 24\oplus 3=111_{\textbf{2}}=7.\]

The direction numbers are computed by shifting the values obtained, e.g.

\[\begin{split}v_1 &= \frac{1}{2}=0.1_{\textbf{2}} \\ v_2 &= \frac{3}{4}=0.11_{\textbf{2}} \\ v_3 &= \frac{7}{8}=0.111_{\textbf{2}} \\ v_4 &= \frac{5}{16}=0.0101_{\textbf{2}}\end{split}\]

and

\[v_5=\frac{7}{32}=0.00111_{\textbf{2}}.\]

The first Sobol’s number is obtained with the first direction number

\[x_1=1(v_1)=v_1=0.1_{\textbf{2}}=0.5.\]

As the binary expansion of two is \(10_{\textbf{2}}\) then

\[x_2=1(v_2)\oplus 0(v_1) =v_2=0.11_{\textbf{2}}=0.75\]

and

\[x_3=v_1\oplus v_2=0.01_{\textbf{2}}=0.25.\]

The following table summarises the construction performed, with the Sobol’s sequence on the two rightmost columns, the next to last in binary and the last in base ten.

\(i,j (10)\) \(i,j\) \(m_j(10)\) \(m_j\) \(v_j\) \(x_i\) \(x_i(10)\)
1 1 1 1 .1 .1 .5
2 10 3 11 .11 .11 .75
3 11 7 111 .111 .01 .25
4 100 5 101 .0101 .111 .875
5 101 7 111 .00111 .011 .375
6 110     .001 .125  
7 111     .101 .625  
8 1000     .0101 .3125  
9 1001     .1101 .8125  
10 1010     .1001 .5625