public class SobolSequenceGenerator extends Object implements RandomVectorGenerator
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)
Constructor and Description |
---|
SobolSequenceGenerator(int dimension)
Construct a new Sobol sequence generator for the given space dimension.
|
SobolSequenceGenerator(int dimension,
InputStream 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 |
---|---|
int |
getNextIndex()
Returns the index i of the next point in the Sobol sequence that will be returned
by calling
nextVector() . |
double[] |
nextVector()
Generate a random vector.
|
double[] |
skipTo(int index)
Skip to the i-th point in the Sobol sequence.
|
public SobolSequenceGenerator(int dimension) throws MathIllegalArgumentException
dimension
- the space dimensionMathIllegalArgumentException
- if the space dimension is outside the allowed range of [1, 1000]public SobolSequenceGenerator(int dimension, InputStream is) throws MathIllegalArgumentException, MathIllegalStateException, IOException
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.
dimension
- the space dimensionis
- the stream to read the direction vectors fromMathIllegalArgumentException
- if the space dimension is < 1MathIllegalArgumentException
- if the space dimension is outside the range [1, max], where
max refers to the maximum dimension found in the input streamMathIllegalStateException
- if the content in the stream could not be parsed successfullyIOException
- if an error occurs while reading from the input streampublic double[] nextVector()
nextVector
in interface RandomVectorGenerator
public double[] skipTo(int index) throws MathIllegalArgumentException
This operation can be performed in O(1).
index
- the index in the sequence to skip toMathIllegalArgumentException
- if index < 0public int getNextIndex()
nextVector()
.Copyright © 2016-2022 CS GROUP. All rights reserved.