Sampler APIs

Sample

QuasiMonteCarlo.sampleFunction
sample(n::Integer, d::Integer, S::SamplingAlgorithm, T = Float64)
sample(n::Integer,
    lb::T,
    ub::T,
    S::SamplingAlgorithm) where {T <: Union{Base.AbstractVecOrTuple, Number}}

Return a QMC point set where:

  • n is the number of points to sample.
  • S is the quasi-Monte Carlo sampling strategy. The point set is in a d-dimensional unit box [0, 1]^d. If the bounds are specified, the sample is transformed (translation + scaling) into a box [lb, ub] where:
  • lb is the lower bound for each variable. Its length fixes the dimensionality of the sample.
  • ub is the upper bound. Its dimension must match length(lb).

In the first method the type of the point set is specified by T while in the second method the output type is inferred from the bound types.

source

Samplers

Samplers are divided into two subtypes

abstract type SamplingAlgorithm end
abstract type RandomSamplingAlgorithm <: SamplingAlgorithm end
abstract type DeterministicSamplingAlgorithm <: SamplingAlgorithm end

Deterministic Sampling Algorithm

All DeterministicSamplingAlgorithm have NoRand() as their default RandomizationMethod, see Randomization methods and Design Matrices section for more information on randomization.

QuasiMonteCarlo.GridSampleType
GridSample(R::RandomizationMethod = NoRand()) <: DeterministicSamplingAlgorithm

A simple rectangular grid lattice. Samples n random samples from a grid with dx = (ub -lb)/n`

In more than 2 dimensions, grids have worse discrepancy than simple Monte Carlo. As a result, they should almost never be used for multivariate integration; their use is as a starting point for other algorithms.

source
QuasiMonteCarlo.SobolSampleType
SobolSample(R::RandomizationMethod = NoRand()) <: DeterministicSamplingAlgorithm

Samples taken from Sobol's base-2 sequence.

source
Warning

The QuasiMonteCarlo.jl package relies on the Sobol.jl package to sample Sobol nets. The choice, there is to NOT start the sequence at 0. This is debatable, see this issue and ref therein for more context.

QuasiMonteCarlo.FaureSampleType
FaureSample(R::RandomizationMethod = NoRand()) <: DeterministicSamplingAlgorithm

A Faure low-discrepancy sequence.

Faure-distributed samples cover all dimensions evenly, using the same set of points for all variables, up to ordering.

When scrambled, randomized Faure sequences provide worst-case guarantees that variance will be at most exp(1) ≈ 2.718 times greater than for a purely Monte Carlo integral. However, they are much less efficient than the Sobol sequence at integrating functions with low effective dimension (functions where the first few inputs dominate the evaluation).

The Faure sequence in dimension s forms a (0, s)-sequence with base b = nextprime(s).

A Faure sequence must have length k * base^s with k < base < 1.

References: Faure, H. (1982). Discrépance de suites associées à un système de numération (en dimension s). Acta Arith., 41, 337-351. Owen, A. B. (1997). Monte Carlo variance of scrambled net quadrature. SIAM Journal on Numerical Analysis, 34(5), 1884-1910.

source
QuasiMonteCarlo.GoldenSampleFunction
GoldenSample()

Generate a quasirandom Kronecker sequence using powers of the generalized golden ratio.

The harmonious, or generalized golden, ratios are defined as the solutions to the equation: $x^d = x + 1$

Where d is the dimension of the sequence. The Golden sequence is then equivalent to Kronecker([x^-i for i in 1:d]).

WARNING: the generalized golden sequence in more than 2 dimensions is purely experimental. It likely has poor discrepancy in high dimensions, and should not be used without verifying answers against a better-known quasirandom sequence. Try a rank-1 lattice rule instead.

References: Roberts, M. (2018). The Unreasonable Effectiveness of Quasirandom Sequences. Extreme Learning. http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/

source
QuasiMonteCarlo.KroneckerSampleType
KroneckerSample(generator::AbstractVector, R::RandomizationMethod = NoRand()) <: DeterministicSamplingAlgorithm

A Kronecker sequence is a point set generated using a vector and equation: x[i] = i * generator .% 1

Where i runs from 1 through the sample size n. This sequence will be equidistributed (uniform in the infinite limit) so long as the components of generator are linearly independent over the field of rational numbers.

If no generator is specified, a lattice based on the generalized golden ratio is used; see GoldenSample for more information.

Kronecker sequences are not recommended for use in more than 3 dimensions, as theory on them is sparse. LatticeRuleSample will return rank-1 lattice rules, which behave similarly to Kronecker sequences but have better properties.

References: Leobacher, G., & Pillichshammer, F. (2014). Introduction to quasi-Monte Carlo integration and applications. Switzerland: Springer International Publishing. https://link.springer.com/content/pdf/10.1007/978-3-319-03425-6.pdf

source

Random Sampling Algorithm

QuasiMonteCarlo.LatinHypercubeSampleType
LatinHypercubeSample(rng::AbstractRNG = Random.GLOBAL_RNG) <: RandomSamplingAlgorithm

A Latin Hypercube is a point set with the property that every one-dimensional interval (i/n, i+1/n) contains exactly one point. This is a good way to sample a high-dimensional space, as it is more uniform than a random sample but does not require as many points as a full net.

source
QuasiMonteCarlo.RandomizedHaltonSampleType
RandomizedHalton(rng::AbstractRNG = Random.GLOBAL_RNG) <: RandomSamplingAlgorithm

Create a randomized Halton sequence.

References:
Owen, A. (2017). *A randomized Halton algorithm in R*. https://doi.org/10.48550/arXiv.1706.02808
source