Sampling
Sampling methods are provided by the QuasiMonteCarlo package.
The syntax for sampling in an interval or region is the following:
sample(n, lb, ub, S::SamplingAlgorithm)
where lb and ub are, respectively, the lower and upper bounds. There are many sampling algorithms to choose from:
- Grid sample
sample(n, lb, ub, GridSample())
- Uniform sample
sample(n, lb, ub, RandomSample())
- Sobol sample
sample(n, lb, ub, SobolSample())
- Latin Hypercube sample
sample(n, lb, ub, LatinHypercubeSample())
- Low Discrepancy sample
sample(n, lb, ub, HaltonSample())
- Sample on section
sample(n, lb, ub, SectionSample())
Adding a new sampling method
Adding a new sampling method is a two-step process:
- Adding a new SamplingAlgorithm type
- Overloading the sample function with the new type.
Example
struct NewAmazingSamplingAlgorithm{OPTIONAL} <: QuasiMonteCarlo.SamplingAlgorithm end
function sample(n, lb, ub, ::NewAmazingSamplingAlgorithm)
if lb isa Number
...
return x
else
...
return Tuple.(x)
end
end