Samples
The syntax for sampling in an interval or region is the following:
sample(n,lb,ub,S::SamplingAlgorithm)
Where lb and ub are respectively lower and upper bound. There are many sampling algorithms to choose from:
- Grid sample
Surrogates.GridSample
— TypeGridSample{T}
T is the step dx for lb:dx:ub
Surrogates.sample
— Methodsample(n,lb,ub,S::GridSample)
Returns a tuple containing numbers in a grid.
- Uniform sample
Surrogates.sample
— Methodsample(n,lb,ub,::UniformRandom)
Returns a Tuple containig uniform random numbers.
- Sobol sample
Surrogates.sample
— Methodsample(n,lb,ub,::SobolSampling)
Returns a Tuple containig Sobol sequences.
- Latin Hypercube sample
Surrogates.sample
— Methodsample(n,lb,ub,::LatinHypercube)
Returns a Tuple containig LatinHypercube sequences.
- Low Discrepancy sample
Surrogates.LowDiscrepancySample
— TypeLowDiscrepancySample{T}
T is the base for the sequence
Surrogates.sample
— Methodsample(n,lb,ub,S::LowDiscrepancySample)
Low discrepancy sample:
- Dimension 1: Van der corput sequence
- Dimension > 1: Halton sequence
If dimension d > 1, every bases must be coprime with each other.
Adding a new sampling method
Adding a new sampling method is a two step process:
- Add a new SamplingAlgorithm type
- Overload the sample function with the new type.
Example
struct NewAmazingSamplingAlgorithm{OPTIONAL} <: SamplingAlgorithm end
function sample(n,lb,ub,::NewAmazingSamplingAlgorithm)
if lb is Number
...
return x
else
...
return Tuple.(x)
end
end