easyvvuq.sampling package¶
Submodules¶
easyvvuq.sampling.base module¶
-
class
easyvvuq.sampling.base.BaseSamplingElement¶ Bases:
easyvvuq.base_element.BaseElementBaseclass for all EasyVVUQ sampling elements.
Variables: sampler_name (str) – Name of the particular sampler. -
analysis_class¶
-
element_category()¶
-
element_name()¶
-
is_finite()¶
-
iteration= 0¶
-
n_samples()¶
-
sampler_id¶
-
easyvvuq.sampling.empty module¶
-
class
easyvvuq.sampling.empty.EmptySampler¶ Bases:
easyvvuq.sampling.base.BaseSamplingElement-
is_finite()¶
-
sampler_name= 'empty'¶
-
easyvvuq.sampling.pce module¶
-
class
easyvvuq.sampling.pce.PCESampler(vary=None, count=0, polynomial_order=4, regression=False, rule='G', sparse=False, growth=False)¶ Bases:
easyvvuq.sampling.base.BaseSamplingElement-
analysis_class¶ Return a corresponding analysis class.
-
is_finite()¶
-
n_samples¶ Number of samples (Ns) of PCE method. - When using pseudo-spectral projection method with tensored
quadrature: Ns = (p + 1)**d- When using pseudo-spectral projection method with sparce grid quadratue: Ns = bigO((p + 1)*log(p + 1)**(d-1))
- When using regression method: Ns = 2*(p + d)!/p!*d!
Where: p is the polynomial degree and d is the number of uncertain parameters.
Ref: Eck et al. ‘A guide to uncertainty quantification and sensitivity analysis for cardiovascular applications’ [2016].
-
sampler_name= 'PCE_sampler'¶
-
easyvvuq.sampling.qmc module¶
This sampler is meant to be used with the QMC Analysis module.
-
class
easyvvuq.sampling.qmc.QMCSampler(vary, n_mc_samples, count=0)¶ Bases:
easyvvuq.sampling.base.BaseSamplingElement-
analysis_class¶ Return a corresponding analysis class.
-
is_finite()¶ Can this sampler produce only a finite number of samples.
-
n_samples¶ Returns the number of samples in this sampler.
Returns: - This computed with the formula (d + 2) * N, where d is the number
- of uncertain parameters and N is the (estimated) number of samples
- for the Monte Carlo method.
-
sampler_name= 'QMC_sampler'¶
-
easyvvuq.sampling.quasirandom module¶
Summary¶
This module provides classes based on RandomSampler but modified in such a way that the output of the sampler is not random but is meant to be used in place of uniformly random number sequences. Usually this is used to cover the sampling space more “evenly” than a uniform random distribution would. Two methods are implemented:
https://en.wikipedia.org/wiki/Latin_hypercube_sampling https://en.wikipedia.org/wiki/Halton_sequence
-
class
easyvvuq.sampling.quasirandom.HaltonSampler(vary=None, count=0, max_num=0)¶ Bases:
easyvvuq.sampling.random.RandomSampler-
sampler_name= 'halton_sampler'¶
-
-
class
easyvvuq.sampling.quasirandom.LHCSampler(vary=None, count=0, max_num=0)¶ Bases:
easyvvuq.sampling.random.RandomSampler-
sampler_name= 'lhc_sampler'¶
-
easyvvuq.sampling.random module¶
-
class
easyvvuq.sampling.random.RandomSampler(vary=None, count=0, max_num=0)¶ Bases:
easyvvuq.sampling.base.BaseSamplingElement-
element_version()¶
-
is_finite()¶
-
n_samples()¶ Returns the number of samples in this sampler. :returns: :rtype: if the user specifies maximum number of samples than return that, otherwise - error
-
sampler_name= 'random_sampler'¶
-
easyvvuq.sampling.replica_sampler module¶
Replica Sampler
Summary¶
Primarily intended for sampling the same paramater values but with different random seed. Other uses may be possible. It takes a finite sampler and produces an infinite sampler from it. This infinite sampler loops through the parameters produced by the finite sampler and at each cycle adds a unique id number for that cycle to the parameter dictionary.
-
class
easyvvuq.sampling.replica_sampler.ReplicaSampler(sampler, replica_col='ensemble_id', seed_col=None, replicas=0)¶ Bases:
easyvvuq.sampling.base.BaseSamplingElementReplica Sampler
Parameters: - sampler (an instance of a class derived from BaseSamplingElement) – a finite sampler to loop over
- replica_col (string) – a parameter name for the replica id
- seed_col (string) – a parameter name for the input parameter that specifies the RNG seed
- replicas (int) – number of replicas, if zero will result in an infinite sampler
-
analysis_class¶
-
inputs¶
-
is_finite()¶
-
iteration¶ int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
n_samples()¶
-
qoi¶
-
reset()¶
-
sampler_name= 'replica_sampler'¶
-
update(result, invalid)¶
easyvvuq.sampling.sampler_of_samplers module¶
-
class
easyvvuq.sampling.sampler_of_samplers.MultiSampler(*samplers, count=0)¶ Bases:
easyvvuq.sampling.base.BaseSamplingElement-
is_finite()¶
-
n_samples()¶ Returns the number of samples in this sampler.
Returns: Return type: a product of the sizes of samplers passed to MultiSampler
-
sampler_name= 'multisampler'¶
-
easyvvuq.sampling.stochastic_collocation module¶
-
class
easyvvuq.sampling.stochastic_collocation.SCSampler(vary=None, polynomial_order=4, quadrature_rule='G', count=0, growth=False, sparse=False, midpoint_level1=True, dimension_adaptive=False)¶ Bases:
easyvvuq.sampling.base.BaseSamplingElementStochastic Collocation sampler
-
analysis_class¶ Return a corresponding analysis class.
-
check_max_quad_level()¶ If a discrete variable is specified, there is the possibility of non unique collocation points if the quadrature order is high enough. This subroutine prevents that.
NOTE: Only detects cp.DiscreteUniform thus far
The max quad orders are stores in self.max_quad_order
Returns: Return type: None
-
compute_1D_points_weights(L, N)¶ Computes 1D collocation points and quad weights, and stores this in self.xi_1d, self.wi_1d.
Parameters: - L ((int) the max level of the (sparse) grid)
- N ((int) the number of uncertain parameters)
Returns: Return type: None.
-
compute_sparse_multi_idx(L, N)¶ computes all N dimensional multi-indices l = (l1,…,lN) such that |l| <= L + N - 1, i.e. a simplex set: 3 * 2 * * (L=3 and N=2) 1 * * *
1 2 3Here |l| is the internal sum of i (l1+…+lN)
-
generate_grid(l_norm)¶
-
is_finite()¶
-
load_state(filename)¶
-
look_ahead(current_multi_idx)¶ The look-ahead step in dimension-adaptive sparse grid sampling. Allows for anisotropic sampling plans.
Computes the admissible forward neighbors with respect to the current level multi-indices. The admissible level indices l are added to self.admissible_idx. The code will be evaluated next iteration at the new collocation points corresponding to the levels in admissble_idx.
Source: Gerstner, Griebel, “Numerical integration using sparse grids”
Parameters: - current_multi_idx (array of the levels in the current iteration)
- of the sparse grid.
Returns: Return type: None.
-
n_samples¶ Number of samples (Ns) of SC method. - When using tensor quadrature: Ns = (p + 1)**d - When using sparid: Ns = bigO((p + 1)*log(p + 1)**(d-1)) Where: p is the polynomial degree and d is the number of uncertain parameters.
Ref: Eck et al. ‘A guide to uncertainty quantification and sensitivity analysis for cardiovascular applications’ [2016].
-
next_level_sparse_grid()¶ Adds the points of the next level for isotropic hierarchical sparse grids.
Returns: Return type: None.
-
sampler_name= 'sc_sampler'¶
-
save_state(filename)¶
-
-
easyvvuq.sampling.stochastic_collocation.setdiff2d(X, Y)¶ Computes the difference of two 2D arrays X and Y
Parameters: - X (2D numpy array)
- Y (2D numpy array)
Returns: Return type: The difference X Y as a 2D array
easyvvuq.sampling.sweep module¶
-
class
easyvvuq.sampling.sweep.BasicSweep(sweep=None, count=0)¶ Bases:
easyvvuq.sampling.base.BaseSamplingElement-
is_finite()¶
-
n_samples()¶ Returns the number of samples in this sampler.
Returns: Return type: a product of the lengths of lists passed to BasicSweep
-
sampler_name= 'basic_sweep'¶
-
-
easyvvuq.sampling.sweep.wrap_iterable(var_name, iterable)¶