A Halton sequence is a low-discrepancy sequence generating points in the interval [0, 1] according to
H(n) = d_0 / b + d_1 / b^2 .... d_j / b^j+1 with n = d_j * b^j-1 + ... d_1 * b + d_0 * b^0For higher dimensions, subsequent prime numbers are used as base, e.g. { 2, 3, 5 } for a Halton sequence in R^3.
Halton sequences are known to suffer from linear correlation for larger prime numbers, thus the individual digits are usually scrambled. This implementation already comes with support for up to 40 dimensions with optimal weight numbers from H. Chi: Scrambled quasirandom sequences and their applications.
The generator supports two modes:
nextVector()skipTo(int)| Modifier and Type | Field and Description |
|---|---|
| private final int[] | base
The base numbers for each component. |
| private int | count
The current index in the sequence. |
| private final int | dimension
Space dimension. |
| private static final int[] | PRIMES
The first 40 primes. |
| private final int[] | weight
The scrambling weights for each component. |
| private static final int[] | WEIGHTS
The optimal weights used for scrambling of the first 40 dimension. |
| Access | Constructor and Description |
|---|---|
| public | HaltonSequenceGenerator(final int
the space dimension dimension)Construct a new Halton sequence generator for the given space dimension. |
| public | HaltonSequenceGenerator(final int
the space dimension dimension, final int[] the base number for each dimension, entries should be (pairwise) prime, may not be null bases, final int[] the weights used during scrambling, may be null in which case no scrambling will be performed weights)Construct a new Halton sequence generator with the given base numbers and weights for each dimension. |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: the index of the next pointReturns the index i of the next point in the Halton sequence that will be returned
by calling |
| public double[] | nextVector()
Implements org. Generate a random vector. |
| protected int | Returns: the scrambled digitthe dimension index i, final int the digit index j, final int the base for this dimension b, final int the j-th digit digit)Performs scrambling of digit ( weight_i * d_j ) mod base |
| public double[] | Returns: the i-th point in the Halton sequencethe index in the sequence to skip to index)Skip to the i-th point in the Halton sequence. |
| base | back to summary |
|---|---|
| private final int[] base The base numbers for each component. | |
| count | back to summary |
|---|---|
| private int count The current index in the sequence. | |
| dimension | back to summary |
|---|---|
| private final int dimension Space dimension. | |
| PRIMES | back to summary |
|---|---|
| private static final int[] PRIMES The first 40 primes. | |
| weight | back to summary |
|---|---|
| private final int[] weight The scrambling weights for each component. | |
| WEIGHTS | back to summary |
|---|---|
| private static final int[] WEIGHTS The optimal weights used for scrambling of the first 40 dimension. | |
| HaltonSequenceGenerator | back to summary |
|---|---|
| public HaltonSequenceGenerator(final int dimension) throws OutOfRangeException Construct a new Halton sequence generator for the given space dimension.
| |
| HaltonSequenceGenerator | back to summary |
|---|---|
| public HaltonSequenceGenerator(final int dimension, final int[] bases, final int[] weights) throws NullArgumentException, OutOfRangeException, DimensionMismatchException Construct a new Halton sequence generator with the given base numbers and weights for each dimension. The length of the bases array defines the space dimension and is required to be > 0.
| |
| getNextIndex | back to summary |
|---|---|
| public int getNextIndex() Returns the index i of the next point in the Halton sequence that will be returned
by calling
| |
| nextVector | back to summary |
|---|---|
| public double[] nextVector() Implements org. Doc from org. Generate a random vector.
| |
| scramble | back to summary |
|---|---|
| protected int scramble(final int i, final int j, final int b, final int digit) Performs scrambling of digit ( weight_i * d_j ) mod baseImplementations can override this method to do a different scrambling.
| |
| skipTo | back to summary |
|---|---|
| public double[] skipTo(final int index) throws NotPositiveException Skip to the i-th point in the Halton sequence. This operation can be performed in O(1).
| |