Developer API for sampling methods¶
SamplingMethod¶
A base class for all sampling methods in SMT.
- class smt.sampling_methods.sampling_method.SamplingMethod(**kwargs)[source]¶
Methods
__call__
([nt])Compute the samples.
- _initialize(**kwargs) None [source]¶
Implemented by sampling methods to declare options and/or use these optional values for initialization (optional)
- Parameters:
- **kwargsnamed arguments passed by the user
Set of options that can be optionally set
Examples
self.options.declare(‘option_name’, default_value, types=(bool, int), desc=’description’)
- abstractmethod _compute(nt: int = None) ndarray [source]¶
Implemented by sampling methods to compute the samples. Depending on the concrete sampling method the requested number of samples nt may not be enforced.
The number of dimensions (nx) is determined based on xlimits.shape[0].
- Parameters:
- ntint
Number of points requested. Depending on the concrete sampling method this requested number of samples may not be enforced.
- Returns:
- ndarray[nt, nx]
The sampling locations in the input space.
ScaledSamplingMethod¶
Conveniently, if a sampling method generates samples in the [0, 1] hypercube, one can inherit from the subclass ScaledSamplingMethod which automates the scaling from unit hypercube to the input space (i.e. xlimits).
- class smt.sampling_methods.sampling_method.ScaledSamplingMethod(**kwargs)[source]¶
This class represents sample methods which generates samples in the unit hypercube [0, 1]^nx.
The __call__ method does scale the generated samples accordingly to the defined xlimits.
Implementation notes:
When nt is None, it defaults to 2 * nx.
xlimits is presence is checked. ValueError is raised if not specified.
Methods
__call__
([nt])Compute the samples.
- abstractmethod _compute(nt: int = None) ndarray [source]¶
Implemented by sampling methods to compute the requested number of sampling points.
The number of dimensions (nx) is determined based on xlimits.shape[0].
- Parameters:
- ntint
Number of points requested.
- Returns:
- ndarray[nt, nx]
The sampling locations in the unit hypercube.