HaltonSequences

This package provides a convenient interface to computing terms from individual or multidimensional Halton sequences. These are low-discrepancy sequences widely applied in quasi-Monte Carlo methods. They are well known to have shortcomings in moderate to high dimensions, however.

Usage

The primary tools offered are the Array-like Halton and HaltonPoint types. These generate on-demand values of individual or multidimensional sequences, respectively.

To make a Halton object, you provide a prime base. For example,

julia> using HaltonSequences
julia> h = Halton(2)4294967295-element Halton{Float64}: 0.5 0.25 0.75 0.125 0.625 0.375 0.875 0.0625 0.5625 0.3125 ⋮ 0.9374999997671694 0.12499999976716936 0.6249999997671694 0.37499999976716936 0.8749999997671694 0.24999999976716936 0.7499999997671694 0.49999999976716936 0.9999999997671694

As you can see, you get a fairly long virtual Vector by default. However, values are computed only when elements are accessed. To store values, collect them into an ordinary array.

julia> collect( h[1:6] )6-element Vector{Float64}:
 0.5
 0.25
 0.75
 0.125
 0.625
 0.375

You can specify offsets from the sequence start, or a different length, using keywords. You can also specify different Real types for the values.

julia> Halton(2,start=64)[1]0.0078125
julia> Halton{Rational}(3,length=7)7-element Halton{Rational}:
 1//3
 2//3
 1//9
 4//9
 7//9
 2//9
 5//9

To make a HaltonPoint object, give the dimension of the sequence values.

julia> HaltonPoint(4)[1:6]6-element Vector{Vector{Float64}}:
 [0.5, 0.3333333333333333, 0.2, 0.14285714285714285]
 [0.25, 0.6666666666666666, 0.4, 0.2857142857142857]
 [0.75, 0.1111111111111111, 0.6000000000000001, 0.42857142857142855]
 [0.125, 0.4444444444444444, 0.8, 0.5714285714285714]
 [0.625, 0.7777777777777777, 0.04, 0.7142857142857142]
 [0.375, 0.2222222222222222, 0.24000000000000002, 0.8571428571428571]

The sequence elements are vectors of the base element type. By default, the bases of the different dimensions are chosen in order starting with 2. You may instead give a vector of prime bases.

julia> HaltonPoint{Rational}([7,11,13],length=6)6-element HaltonPoint{Rational}:
 Rational{Int64}[1//7, 1//11, 1//13]
 Rational{Int64}[2//7, 2//11, 2//13]
 Rational{Int64}[3//7, 3//11, 3//13]
 Rational{Int64}[4//7, 4//11, 4//13]
 Rational{Int64}[5//7, 5//11, 5//13]
 Rational{Int64}[6//7, 6//11, 6//13]