A Sobol sequence is a low-discrepancy sequence with the property that for all values of N, its subsequence (x1, ... xN) has a low discrepancy. It can be used to generate pseudo-random points in a space S, which are equi-distributed.
The implementation already comes with support for up to 1000 dimensions with direction numbers calculated from Stephen Joe and Frances Kuo.
The generator supports two modes:
nextVector()skipTo(int)| Modifier and Type | Field and Description |
|---|---|
| private static final int | BITS
The number of bits to use. |
| private int | count
The current index in the sequence. |
| private final int | dimension
Space dimension. |
| private final long[][] | direction
The direction vector for each component. |
| private static final String | FILE_CHARSET
Character set for file input. |
| private static final int | MAX_DIMENSION
The maximum supported space dimension. |
| private static final String | RESOURCE_NAME
The resource containing the direction numbers. |
| private static final double | SCALE
The scaling factor. |
| private final long[] | x
The current state. |
| Access | Constructor and Description |
|---|---|
| public | SobolSequenceGenerator(final int
the space dimension dimension)Construct a new Sobol sequence generator for the given space dimension. |
| public | SobolSequenceGenerator(final int
the space dimension dimension, final InputStream the stream to read the direction vectors from is)Construct a new Sobol sequence generator for the given space dimension with direction vectors loaded from the given stream. |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: the index of the next pointReturns the index i of the next point in the Sobol sequence that will be returned
by calling |
| private void | initDirectionVector(final int
the dimension, zero-based d, final int the coefficients of the primitive polynomial a, final int[] the initial direction numbers m)Calculate the direction numbers from the given polynomial. |
| private int | Returns: the last dimension that has been read from the input streamthe input stream to read the direction vector from is)Load the direction vector for each dimension from the given stream. |
| public double[] | nextVector()
Implements org. Generate a random vector. |
| public double[] | Returns: the i-th point in the Sobol sequencethe index in the sequence to skip to index)Skip to the i-th point in the Sobol sequence. |
| BITS | back to summary |
|---|---|
| private static final int BITS The number of bits to use. | |
| count | back to summary |
|---|---|
| private int count The current index in the sequence. | |
| dimension | back to summary |
|---|---|
| private final int dimension Space dimension. | |
| direction | back to summary |
|---|---|
| private final long[][] direction The direction vector for each component. | |
| FILE_CHARSET | back to summary |
|---|---|
| private static final String FILE_CHARSET Character set for file input. | |
| MAX_DIMENSION | back to summary |
|---|---|
| private static final int MAX_DIMENSION The maximum supported space dimension. | |
| RESOURCE_NAME | back to summary |
|---|---|
| private static final String RESOURCE_NAME The resource containing the direction numbers. | |
| SCALE | back to summary |
|---|---|
| private static final double SCALE The scaling factor. | |
| x | back to summary |
|---|---|
| private final long[] x The current state. | |
| SobolSequenceGenerator | back to summary |
|---|---|
| public SobolSequenceGenerator(final int dimension) throws OutOfRangeException Construct a new Sobol sequence generator for the given space dimension.
| |
| SobolSequenceGenerator | back to summary |
|---|---|
| public SobolSequenceGenerator(final int dimension, final InputStream is) throws NotStrictlyPositiveException, MathParseException, IOException Construct a new Sobol sequence generator for the given space dimension with direction vectors loaded from the given stream. The expected format is identical to the files available from Stephen Joe and Frances Kuo. The first line will be ignored as it is assumed to contain only the column headers. The columns are:
d s a m_i 2 1 0 1 3 2 1 1 3 The input stream must be an ASCII text containing one valid direction vector per line.
| |
| getNextIndex | back to summary |
|---|---|
| public int getNextIndex() Returns the index i of the next point in the Sobol sequence that will be returned
by calling
| |
| initDirectionVector | back to summary |
|---|---|
| private void initDirectionVector(final int d, final int a, final int[] m) Calculate the direction numbers from the given polynomial.
| |
| initFromStream | back to summary |
|---|---|
| private int initFromStream(final InputStream is) throws MathParseException, IOException Load the direction vector for each dimension from the given stream. The input stream must be an ASCII text containing one valid direction vector per line.
| |
| nextVector | back to summary |
|---|---|
| public double[] nextVector() Implements org. Doc from org. Generate a random vector.
| |
| skipTo | back to summary |
|---|---|
| public double[] skipTo(final int index) throws NotPositiveException Skip to the i-th point in the Sobol sequence. This operation can be performed in O(1).
| |