Refined Stratified Sampling
Refined Stratified Sampling (RSS) is a sequential sampling procedure that adaptively refines the stratification of the
parameter space to add samples. There are four variations of RSS currently available in UQpy
. First, the procedure
works with either rectangular stratification (i.e. using Rectangular
) or Voronoi stratification
(i.e. using Voronoi
). For each of these, two refinement procedures are available. The first is a randomized
algorithm where strata are selected at random according to their probability weight. This algorithm is described
in [19]. The second is a gradient-enhanced version (so-called GE-RSS) that draws samples in strata that possess both
large probability weight and have high variance. This algorithm is described in [20].
Refined Stratified Sampling Class
All variations of Refined Stratifed Sampling are implemented in the RefinedStratifiedSampling
class.
This class provides the framework for refined stratified sampling. with the aid of an underlying stratification generated
in a previous sampling of type TrueStratifiedSampling
, as well as a Refinement
algorithm an adaptive
sampling and refinement of the stratification can be performed.
The RefinedStratifiedSampling
class is imported using the following command:
>>> from UQpy.sampling.stratified_sampling.RefinedStratifiedSampling import RefinedStratifiedSampling
Methods
- class RefinedStratifiedSampling(stratified_sampling, refinement_algorithm, nsamples=None, samples_per_iteration=1, random_state=None)[source]
- Parameters:
stratified_sampling (
TrueStratifiedSampling
) – Generally, this must be an object of aTrueStratifiedSampling
class.refinement_algorithm (
Refinement
) – Algorithm used for the refinement of the strata. Two methods existRandomRefinement
andGradientEnhancedRefinement
.nsamples (
Optional
[int
]) – Total number of samples to be drawn (including the initial samples). If nsamples is provided when instantiating the class, therun()
method will automatically be called. If nsamples is not provided,RefinedStratifiedSampling
can be executed by invoking therun()
method and passing nsamplessamples_per_iteration (
int
) – Number of samples to be added per refinement iteration.random_state (
Union
[None
,int
,RandomState
]) – Random seed used to initialize the pseudo-random number generator. Default isNone
. If anint
is provided, this sets the seed for an object ofnumpy.random.RandomState
. Otherwise, the object itself can be passed directly.
- run(nsamples)[source]
Executes refined stratified sampling.
- Parameters:
nsamples (
int
) – Total number of samples to be drawn (including the initial samples). If nsamples is provided when instantiating the class, therun()
method will automatically be called. If nsamples is not provided, anRefinedStratifiedSampling
subclass can be executed by invoking therun()
method and passing nsamples
Attributes
Examples
Stratification Refinement Algorithms
The RefinedStratifiedSampling
allows for an adaptive refinement of existing strata. This adaptive refinement
procedure can be performed based on different algorithms. Each algorithm provides a different approach on selecting and
refining the available Strata
, which can be either randomly, or based on advanced selection techniques.
In order to accommodate all possible refinement procedures, the Refinement
baseclass is created. The user only
needs to implement the update_samples()
method, thus allowing the implementation of different adaptive strata
refinement techniques.
- class Refinement[source]
Baseclass of all available strata refinement methods. Provides the methods that each existing and new refinement algorithm must implement in order to be used in the
RefinedStratifiedSampling
class.- abstract update_samples(nsamples, samples_per_iteration, random_state, index, dimension, samples_u01, training_points)[source]
Method that need to be overridden in case of new
Refinement
techniques.- Parameters:
nsamples (
int
) – Total number of samples to be drawnsamples_per_iteration (
int
) – New samples to be drawn at each refinement iteration.random_state (
Union
[None
,int
,RandomState
]) – Random seed used to initialize the pseudo-random number generator. Default isNone
. If anint
is provided, this sets the seed for an object ofnumpy.random.RandomState
. Otherwise, the object itself can be passed directly.index (
int
) – Iteration indexdimension (
int
) – Number of dimension of the sampling problem.samples_u01 (
ndarray
) – Existing samples drawn at the unit hypercube space.training_points (
ndarray
) – Training points required in case of advanced refinement techniques.
The RandomRefinement
class is imported using the following command:
>>> from UQpy.sampling.stratified_sampling.refinement.RandomRefinement import RandomRefinement
- class RandomRefinement(strata)[source]
Randomized refinement algorithm. Strata to be refined are selected at random according to their probability weights.
- Parameters:
strata –
Strata
object containing already stratified domain to be adaptively sampled usingRefinedStratifiedSampling
The GradientEnhancedRefinement
class is imported using the following command:
>>> from UQpy.sampling.stratified_sampling.refinement.GradientEnhancedRefinement import GradientEnhancedRefinement
- class GradientEnhancedRefinement(strata, runmodel_object, surrogate, nearest_points_number=None, qoi_name=None, step_size=0.005)[source]
Gradient-enhanced version (so-called GE-RSS) refinement algorithm. Draws samples in strata that possess both large probability weight and have high variance.
- Parameters:
strata (
Strata
) –Strata
object containing already stratified domain to be adaptively sampled usingRefinedStratifiedSampling
runmodel_object (
RunModel
) – ARunModel
object, which is used to evaluate the model. It is used to compute the gradient of the model in each stratum.surrogate (
Union
[Surrogate
,GaussianProcessRegressor
,object
]) – An object defining a surrogate model.This object must have thefit()
andpredict()
methods. This parameter aids in computing the gradient.nearest_points_number (
Optional
[int
]) – Specifies the number of nearest points at which to update the gradient.qoi_name (
Optional
[str
]) – Name of the quantity of interest from the runmodel_object. If the quantity of interest is a dictionary, this used to convert it to a list.step_size (
float
) – Defines the size of the step to use for gradient estimation using the central difference method.