Class HaltonSequenceGenerator

    • Constructor Detail

      • HaltonSequenceGenerator

        public HaltonSequenceGenerator​(int dimension)
                                throws MathIllegalArgumentException
        Construct a new Halton sequence generator for the given space dimension.
        Parameters:
        dimension - the space dimension
        Throws:
        MathIllegalArgumentException - if the space dimension is outside the allowed range of [1, 40]
      • HaltonSequenceGenerator

        public HaltonSequenceGenerator​(int dimension,
                                       int[] bases,
                                       int[] weights)
                                throws MathIllegalArgumentException,
                                       NullArgumentException
        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.
        Parameters:
        dimension - the space dimension
        bases - the base number for each dimension, entries should be (pairwise) prime, may not be null
        weights - the weights used during scrambling, may be null in which case no scrambling will be performed
        Throws:
        NullArgumentException - if base is null
        MathIllegalArgumentException - if the space dimension is outside the range [1, len], where len refers to the length of the bases array
        MathIllegalArgumentException - if weights is non-null and the length of the input arrays differ
    • Method Detail

      • nextVector

        public double[] nextVector()
        Generate a random vector.
        Specified by:
        nextVector in interface RandomVectorGenerator
        Returns:
        a random vector as an array of double.
      • scramble

        protected int scramble​(int i,
                               int j,
                               int b,
                               int digit)
        Performs scrambling of digit d_j according to the formula:
           ( weight_i * d_j ) mod base
         
        Implementations can override this method to do a different scrambling.
        Parameters:
        i - the dimension index
        j - the digit index
        b - the base for this dimension
        digit - the j-th digit
        Returns:
        the scrambled digit
      • skipTo

        public double[] skipTo​(int index)
                        throws MathIllegalArgumentException
        Skip to the i-th point in the Halton sequence.

        This operation can be performed in O(1).

        Parameters:
        index - the index in the sequence to skip to
        Returns:
        the i-th point in the Halton sequence
        Throws:
        MathIllegalArgumentException - if index < 0
      • getNextIndex

        public int getNextIndex()
        Returns the index i of the next point in the Halton sequence that will be returned by calling nextVector().
        Returns:
        the index of the next point