SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
SobolSequence Class Reference

This class implements digital nets and digital sequences in base 2 formed by the first \(n = 2^k\) points of a Sobol’ sequence [221], [222]. More...

Inheritance diagram for SobolSequence:
[legend]
Collaboration diagram for SobolSequence:
[legend]

Public Member Functions

 SobolSequence (int k, int w, int dim)
 Constructs a new digital net with \(n = 2^k\) points and \(w\) output digits, in dimension dim, formed by taking the first \(n\) points of the Sobol’ sequence. More...
 
 SobolSequence (int n, int dim)
 Constructs a Sobol point set with at least n points and 31 output digits, in dimension dim. More...
 
 SobolSequence (String filename, int k, int w, int dim)
 Constructs a new digital net using the direction numbers provided in file filename. More...
 
String toString ()
 
void extendSequence (int k)
 
- Public Member Functions inherited from DigitalSequenceBase2
abstract void extendSequence (int k)
 Increases the number of points to \(n = 2^k\) from now on. More...
 
DigitalNetBase2 toNet ()
 Transforms this digital sequence into a digital net without changing the coordinates of the points. More...
 
DigitalNetBase2 toNetShiftCj ()
 Transforms this digital sequence into a digital net by adding one dimension and shifting all coordinates by one position. More...
 
PointSetIterator iteratorShift ()
 Similar to iterator, except that the first coordinate of the points is \(i/n\), the second coordinate is obtained via the generating matrix \(\mathbf{C}_0\), the next one via \(\mathbf{C}_1\), and so on. More...
 
PointSetIterator iteratorShiftNoGray ()
 This iterator shifts all coordinates of each point one position to the right and sets the first coordinate of point \(i\) to \(i/n\), so that the points enumerated with this iterator have one more dimension. More...
 
- Public Member Functions inherited from DigitalNetBase2
void printGeneratorMatrices (int s)
 Prints the generator matrices as bit matrices in standard form for dimensions 1 to \(s\). More...
 
void printGeneratorMatricesTrans (int s)
 Prints the generator matrices transposed in the form of integers for dimensions 1 to \(s\). More...
 
double getCoordinate (int i, int j)
 
double getCoordinateNoGray (int i, int j)
 
PointSetIterator iterator ()
 Returns a DigitalNetBase2Iterator which enumerates the points using a Gray code.
 
PointSetIterator iteratorNoGray ()
 This iterator does not use the Gray code. More...
 
String toString ()
 
void clearRandomShift ()
 
void addRandomShift (int d1, int d2, RandomStream stream)
 
void addRandomShift (RandomStream stream)
 
void leftMatrixScramble (RandomStream stream)
 
void iBinomialMatrixScramble (RandomStream stream)
 
void stripedMatrixScramble (RandomStream stream)
 
void rightMatrixScramble (RandomStream stream)
 
void nestedUniformScramble (RandomStream stream, double[][] output)
 Same as nestedUniformScramble(stream, output, 0) .
 
void nestedUniformScramble (RandomStream stream, double[][] output, int numBits)
 Apply Owen's nested uniform scrambling. More...
 
void leftMatrixScrambleDiag (RandomStream stream)
 
void leftMatrixScrambleFaurePermut (RandomStream stream, int sb)
 
void leftMatrixScrambleFaurePermutDiag (RandomStream stream, int sb)
 
void leftMatrixScrambleFaurePermutAll (RandomStream stream, int sb)
 
void iBinomialMatrixScrambleFaurePermut (RandomStream stream, int sb)
 
void iBinomialMatrixScrambleFaurePermutDiag (RandomStream stream, int sb)
 
void iBinomialMatrixScrambleFaurePermutAll (RandomStream stream, int sb)
 
void stripedMatrixScrambleFaurePermutAll (RandomStream stream, int sb)
 
- Public Member Functions inherited from DigitalNet
 DigitalNet ()
 Empty constructor.
 
double getCoordinate (int i, int j)
 Returns \(u_{i',j}\), the coordinate \(j\) of point \(i'\), where \(i'\) is the Gray code for \(i\). More...
 
PointSetIterator iterator ()
 
double getCoordinateNoGray (int i, int j)
 Returns \(u_{i,j}\), the coordinate \(j\) of point \(i\), the points being enumerated in the standard order (no Gray code). More...
 
PointSetIterator iteratorNoGray ()
 Returns an iterator that does not use the Gray code. More...
 
void addRandomShift (int d1, int d2, RandomStream stream)
 Generates a random digital shift for coordinates \(j\) from d1 to d2-1, using stream to generate the random numbers. More...
 
void addRandomShift (RandomStream stream)
 Same as addRandomShift(0, dim, stream), where dim is the dimension of the digital net. More...
 
void clearRandomShift ()
 Erases the current digital random shift, if any.
 
String toString ()
 Formats a string that contains information on this digital net. More...
 
void leftMatrixScramble (RandomStream stream)
 Applies a linear scramble by multiplying each \(\mathbf{C}_j\) on the left by a \(w\times w\) nonsingular lower-triangular matrix. More...
 
void leftMatrixScrambleDiag (RandomStream stream)
 Similar to leftMatrixScramble except that all the off-diagonal elements of the \(\mathbf{M}_j\) are 0. More...
 
void leftMatrixScrambleFaurePermut (RandomStream stream, int sb)
 Similar to leftMatrixScramble except that the diagonal elements of each matrix \(\mathbf{M}_j\) are chosen from a restricted set of the best integers as calculated by Faure [59] . More...
 
void leftMatrixScrambleFaurePermutDiag (RandomStream stream, int sb)
 Similar to leftMatrixScrambleFaurePermut except that all off-diagonal elements are 0. More...
 
void leftMatrixScrambleFaurePermutAll (RandomStream stream, int sb)
 Similar to leftMatrixScrambleFaurePermut except that the elements under the diagonal are also chosen from the same restricted set as the diagonal elements. More...
 
void iBinomialMatrixScramble (RandomStream stream)
 Applies the \(i\)-binomial matrix scramble proposed by Tezuka. More...
 
void iBinomialMatrixScrambleFaurePermut (RandomStream stream, int sb)
 Similar to iBinomialMatrixScramble except that the diagonal elements of each matrix \(\mathbf{M}_j\) are chosen as in leftMatrixScrambleFaurePermut. More...
 
void iBinomialMatrixScrambleFaurePermutDiag (RandomStream stream, int sb)
 Similar to iBinomialMatrixScrambleFaurePermut except that all the off-diagonal elements are 0. More...
 
void iBinomialMatrixScrambleFaurePermutAll (RandomStream stream, int sb)
 Similar to iBinomialMatrixScrambleFaurePermut except that the elements under the diagonal are also chosen from the same restricted set as the diagonal elements. More...
 
void stripedMatrixScramble (RandomStream stream)
 Applies the striped matrix scramble proposed by Owen. More...
 
void stripedMatrixScrambleFaurePermutAll (RandomStream stream, int sb)
 Similar to stripedMatrixScramble except that the elements on and under the diagonal of each matrix \(\mathbf{M}_j\) are chosen as in leftMatrixScrambleFaurePermut. More...
 
void rightMatrixScramble (RandomStream stream)
 Applies a linear scramble by multiplying each \(\mathbf{C}_j\) on the right by a single \(k\times k\) nonsingular upper-triangular matrix \(\mathbf{M}\), as suggested by Faure and Tezuka. More...
 
void unrandomize ()
 Restores the original generator matrices and removes the random shift.
 
void resetGeneratorMatrices ()
 Restores the original generator matrices. More...
 
void eraseOriginalGeneratorMatrices ()
 Erases the original generator matrices and replaces them by the current ones. More...
 
void printGeneratorMatrices (int s)
 Prints the generator matrices in standard form for dimensions 1 to \(s\).
 
- Public Member Functions inherited from PointSet
int getDimension ()
 Returns the dimension (number of available coordinates) of the points. More...
 
int getNumPoints ()
 Returns the number of points. More...
 
abstract double getCoordinate (int i, int j)
 Returns \(u_{i,j}\), the coordinate \(j\) of the point \(i\). More...
 
PointSetIterator iterator ()
 Constructs and returns a point set iterator. More...
 
void randomize (PointSetRandomization rand)
 Randomizes this point set using the given rand. More...
 
void addRandomShift (int d1, int d2, RandomStream stream)
 By default, this method generates a random shift in the protected double[] array shift, to be used eventually for a random shift modulo 1. More...
 
void addRandomShift (RandomStream stream)
 Same as addRandomShift(0, dim, stream), where dim is the dimension of the point set. More...
 
void addRandomShift (int d1, int d2)
 Refreshes the random shift (generates new uniform values for the random shift coordinates) for coordinates d1 to d2-1, using the saved shiftStream.
 
void addRandomShift ()
 Same as addRandomShift(0, dim), where dim is the dimension of the point set.
 
void clearRandomShift ()
 Erases the current random shift, if any.
 
String toString ()
 Formats a string that contains information about the point set. More...
 
String formatPoints ()
 Same as invoking formatPoints(n, d) with \(n\) and \(d\) equal to the number of points and the dimension of this object, respectively. More...
 
String formatPoints (int n, int d)
 Formats a string that displays the same information as returned by toString, together with the first \(d\) coordinates of the first \(n\) points. More...
 
String formatPoints (PointSetIterator iter)
 Same as invoking formatPoints(iter, n, d) with \(n\) and \(d\) equal to the number of points and the dimension, respectively. More...
 
String formatPoints (PointSetIterator iter, int n, int d)
 Same as invoking formatPoints(n, d), but prints the points by calling iter repeatedly. More...
 
String formatPointsBase (int b)
 Similar to formatPoints(), but the points coordinates are printed in base \(b\). More...
 
String formatPointsBase (int n, int d, int b)
 Similar to formatPoints(n, d), but the points coordinates are printed in base \(b\). More...
 
String formatPointsBase (PointSetIterator iter, int b)
 Similar to formatPoints(iter), but the points coordinates are printed in base \(b\). More...
 
String formatPointsBase (PointSetIterator iter, int n, int d, int b)
 Similar to formatPoints(iter, n, d), but the points coordinates are printed in base \(b\). More...
 
String formatPointsNumbered ()
 Same as invoking formatPointsNumbered(n, d) with \(n\) and \(d\) equal to the number of points and the dimension, respectively. More...
 
String formatPointsNumbered (int n, int d)
 Same as invoking formatPoints(n,d), except that the points are numbered. More...
 

Protected Attributes

int [] poly_from_file
 
int minit_from_file [][]
 
- Protected Attributes inherited from DigitalNetBase2
int [] genMat
 
int [] digitalShift
 
- Protected Attributes inherited from DigitalNet
int b = 0
 
int numCols = 0
 
int numRows = 0
 
int outDigits = 0
 
int [][] genMat
 
int [][] digitalShift
 
double normFactor
 
double [] factor
 
- Protected Attributes inherited from PointSet
double EpsilonHalf = 1.0 / Num.TWOEXP[55]
 To avoid 0 for nextCoordinate when random shifting, we add this to each coordinate.
 
int dim = 0
 Dimension of the points.
 
int numPoints = 0
 Number of points.
 
int dimShift = 0
 Current dimension of the shift. More...
 
int capacityShift = 0
 Number of array elements in the shift vector, always >= dimShift.
 
double [] shift
 This is the shift vector as a double[] array, which contains the current random shift in case we apply a random shift modulo 1. More...
 
RandomStream shiftStream
 Stream used to generate the random shifts. More...
 

Static Protected Attributes

static final int MAXDIM = 360
 Maximal dimension for the primitive polynomials stored in this file.
 
static final int MAXDEGREE = 18
 Maximal degree of the primitive polynomials that are stored.
 
static final int [] poly
 Ordered list of the first MAXDIM primitive polynomials.
 
static final int minit [][]
 The default direction numbers. More...
 
- Static Protected Attributes inherited from PointSet
static final int MAXBITS = 31
 Since Java has no unsigned type, the 32nd bit cannot be used efficiently, so we have only 31 bits. More...
 

Additional Inherited Members

- Protected Member Functions inherited from DigitalNet
void printMat (int N, int[][][] A, String name)
 
void printMat0 (int[][] A, String name)
 
int intToDigitsGray (int b, int i, int numDigits, int[] bary, int[] gray)
 

Detailed Description

This class implements digital nets and digital sequences in base 2 formed by the first \(n = 2^k\) points of a Sobol’ sequence [221], [222].

Values of \(n\) up to \(2^{30}\) are allowed.

In Sobol’s proposal, the generator matrices \(\mathbf{C}_j\) are upper triangular matrices defined by a set of direction numbers

\[ v_{j,c} = m_{j,c} 2^{-c} = \sum_{l=1}^c v_{j,c,l} 2^{-l}, \]

where each \(m_{j,c}\) is an odd integer smaller than \(2^c\), for \(c=1,…,k\) and \(j=0,…,s-1\). The digit \(v_{j,c,l}\) is the element \((l,c)\) of \(\mathbf{C}_j\), so \(v_{j,c}\) represents column \(c\) of \(\mathbf{C}_j\). One can also write

\[ m_{j,c} = \sum_{l=1}^c v_{j,c,l} 2^{c-l}, \]

so column \(c\) of \(\mathbf{C}_j\) contains the \(c\) digits of the binary expansion of \(m_{j,c}\), from the most to the least significant, followed by \(w-c\) zeros, where \(w\) is the number of output digits. Since each \(m_{j,c}\) is odd, the first \(k\) rows of each \(\mathbf{C}_j\) form a non-singular upper triangular matrix whose diagonal elements are all ones.

For each dimension \(j\), the integers \(m_{j,c}\) are defined by selecting a primitive polynomial over \(\mathbb F_2\) of degree \(c_j\),

\[ f_j(z) = z^{c_j} + a_{j,1}z^{c_j-1} + \cdots+ a_{j,c_j}, \]

and the first \(c_j\) integers \(m_{j,0},…,m_{j,c_j-1}\). Then the following integers \(m_{j,c_j}, m_{j, c_j+1}, …\) are determined by the recurrence

\[ m_{j,c} = 2 a_{j,1} m_{j,c-1} \oplus\cdots\oplus2^{c_j-1} a_{j,c_j-1}m_{j,c-c_j+1} \oplus2^{c_j} m_{j,c-c_j}\oplus m_{j,c-c_j} \]

for \(c\ge c_j\), or equivalently,

\[ v_{j,c,l} = a_{j,1} v_{j,c-1,l} \oplus\cdots\oplus a_{j,c_j-1} v_{j,c-c_j+1,l} \oplus v_{j,c-c_j,l}\oplus v_{j,c-c_j,l+c_j} \]

for \(l\ge0\), where \(\oplus\) means bitwise exclusive or (i.e., bitwise addition modulo 2). Sobol’ has shown [221]  that with this construction, if the primitive polynomials \(f_j(z)\) are all distinct, one obtains a \((t,s)\)-sequence whose \(t\)-value does not exceed \(c_0 + \cdots+ c_{s-1} + 1 - s\). He then suggested to list the set of all primitive polynomials over \(\mathbb F_2\) by increasing order of degree, starting with \(f_0(z) \equiv1\) (whose corresponding matrix \(\mathbf{C}_0\) is the identity), and take \(f_j(z)\) as the \((j+1)\)th polynomial in the list, for \(j\ge0\).

This list of primitive polynomials, as well as default choices for the direction numbers, are stored in precomputed tables. The ordered list of primitive polynomials is the same as in [162]; and was taken from Florent Chabaud’s web site, at http://fchabaud.free.fr/. Each polynomial \(f_j(z)\) is stored in the form of the integer \(2^{c_j} + a_{j,1}2^{c_j-1} + \cdots+ a_{j,c_j}\), whose binary representation gives the polynomial coefficients.

For the set of direction numbers, there are several possibilities based on different selection criteria. The original values proposed by Sobol’ and implemented in the code of Bratley and Fox [24] for \(j\le40\) were selected in terms of his properties \(A\) and \(A’\), which are equivalent to \(s\)-distribution with one and two bits of accuracy, respectively. The default direction numbers used in the present class have been taken from [162]. For \(j\le40\), they are the same as in [24]. Other direction numbers can be used by invoking SobolSequence(String,int,int,int) with the name of a file that contains the parameters. Several files of parameters for Sobol sequences are given on the web site of Frances Kuo. Good parameters can also be found by the LatNet Builder software available here

Constructor & Destructor Documentation

◆ SobolSequence() [1/3]

SobolSequence ( int  k,
int  w,
int  dim 
)

Constructs a new digital net with \(n = 2^k\) points and \(w\) output digits, in dimension dim, formed by taking the first \(n\) points of the Sobol’ sequence.

The predefined generator matrices \(\mathbf{C}_j\) are \(w\times k\). Restrictions: \(0\le k\le30\), \(k\le w\) and dim \( \le360\). To use other direction numbers or to create points in higher dimensions, one should use SobolSequence(String,int,int,int) instead of this constructor.

Parameters
kthere will be 2^k points
rnumber of rows of the generator matrices
wnumber of output digits after a random digital shift
dimdimension of the point set

◆ SobolSequence() [2/3]

SobolSequence ( int  n,
int  dim 
)

Constructs a Sobol point set with at least n points and 31 output digits, in dimension dim.

Equivalent to SobolSequence (k, 31, dim) with \(k = \lceil\log_2 n\rceil\).

Parameters
dimdimension of the point set
nminimal number of points

◆ SobolSequence() [3/3]

SobolSequence ( String  filename,
int  k,
int  w,
int  dim 
)

Constructs a new digital net using the direction numbers provided in file filename.

The net has \(n = 2^k\) points, \(w\) output digits and dimension dim. The file can be either on the user’s host, or somewhere on the Internet: in that case, the full url address must be given using either the http or ftp protocol. For example:

net = new SobolSequence( "http://web.maths.unsw.edu.au/~fkuo/sobol/joe-kuo-6.16900", k, w, dim);

The file must have the following format (the first line is treated as a comment by the program and discarded):

dim \(s\) \(a\) \(m_i\)
2 1 0 1
3 2 1 1 3
4 3 1 1 3 1
5 3 2 1 1 1
6 4 1 1 1 3 3
7 4 4 1 3 5 13
\(\vdots\) \(\vdots\)

where dim is the dimension, \(s\) the degree of the polynomial, the binary representation of \(a\) gives the inner coefficients of the polynomial (the first and the last coefficients are always 1), and \(m_i\) are the direction numbers. Thus if \(a = (a_1 a_2 …a_{s-1})_2\) for a given \(s\), then the polynomial is \(x^s + a_1x^{s-1} + a_2x^{s-2} + \cdots+ a_{s-1} x + 1\). For example, if \(s=4\) and \(a=4 = 100_2\), then the polynomial is \(x^4 + x^3 +1\).

Several files of parameters for Sobol sequences in this format are given on F. Kuo’s Web site up to very high dimensions. The different files give parameters that were selected using different criteria. To avoid waiting for a file to download every time a SobolSequence object is created, one should download the desired files and store them locally for faster access by invoking this constructor with the name of a local file.

Parameters
knumber of points is \(2^k\)
wnumber of output digits
dimdimension of the point set
filenamefile containing the direction numbers

Member Data Documentation

◆ minit

final int minit[][]
staticprotected

The default direction numbers.

For \(j > 0\) and \(c < c_j\), minit[j-1][c] contains the integer \(m_{j,c}\). The values for \(j=0\) are not stored, since \(\boldmath{C}_0\) is the identity matrix.


The documentation for this class was generated from the following file: