queens.iterators.sobol_index_gp_uncertainty package#

Submodules#

queens.iterators.sobol_index_gp_uncertainty.estimator module#

Helper classes for estimation of Sobol indices.

class SobolIndexEstimator(parameter_names, calculate_second_order, number_monte_carlo_samples, number_gp_realizations, number_bootstrap_samples, seed_bootstrap_samples, first_order_estimator, estimates_first_order, estimates_second_order, estimates_total_order)[source]#

Bases: object

Sobol Index Estimator class.

number_bootstrap_samples#

number of bootstrap samples

Type:

int

number_parameters#

number of input space dimensions

Type:

int

number_monte_carlo_samples#

number of Monte-Carlo samples

Type:

int

number_gp_realizations#

number of Gaussian process realizations

Type:

int

calculate_second_order#

true if second-order indices are calculated

Type:

bool

estimates_first_order#

first-order index estimates

Type:

xr.DataArray

estimates_second_order#

second-order index estimates

Type:

xr.DataArray

estimates_total_order#

total-order index estimates

Type:

xr.DataArray

first_order_estimator#

estimator for first-order Sobol indices

Type:

string

parameter_names#

list of parameter names

Type:

list

seed_bootstrap_samples#

seed for bootstrap samples

Type:

int

estimate(prediction, num_procs)[source]#

Estimate Sobol indices.

Return estimate for first, second and total-order Sobol indices (for all realizations of the Gaussian process and all bootstrap samples).

Parameters:
  • prediction (xr.Array) – prediction from Gaussian process

  • num_procs (int) – number of processors

Returns:

estimates (dict) – dictionary of Sobol index estimates of different order

classmethod from_config_create(method_options, parameter_names)[source]#

Create estimator from problem description.

Parameters:
  • method_options (dict) – dictionary with method options

  • parameter_names (list) – list of parameter names

Returns:

estimator – SobolIndexEstimator

class SobolIndexEstimatorThirdOrder(parameter_names, calculate_second_order, number_monte_carlo_samples, number_gp_realizations, number_bootstrap_samples, first_order_estimator, calculate_third_order, third_order_parameters, seed_bootstrap_samples, estimates_first_order, estimates_total_order, estimates_second_order, estimates_third_order)[source]#

Bases: SobolIndexEstimator

SobolIndexEstimatorThirdOrder class.

calculate_third_order#

true if third-order indices only are calculated

Type:

bool

estimates_third_order#

third-order index estimates

Type:

xr.DataArray

third_order_parameters#

list of parameter combination for third-order index

Type:

list

estimate(prediction, num_procs)[source]#

Estimate third-order Sobol index.

Return estimate for third-order Sobol index (for all realizations of the Gaussian process and all bootstrap samples).

Parameters:
  • prediction (xr.Array) – prediction from Gaussian process

  • num_procs (int) – number of processors

Returns:

estimates (dict) – estimates for Sobol indices of different order

classmethod from_config_create(method_options, parameter_names)[source]#

Create estimator from problem description.

Parameters:
  • method_options (dict) – dictionary with method options

  • parameter_names (list) – list of parameter names

Returns:

estimator – SobolIndexEstimatorThirdOrder

queens.iterators.sobol_index_gp_uncertainty.predictor module#

Helper classes for Gaussian process prediction for Sobol indices.

class Predictor(gp_model, number_gp_realizations, seed_posterior_samples)[source]#

Bases: object

Predictor class.

Predict the output of the Gaussian process used as a surrogate model at all Monte-Carlo samples stored in the sample matrices (A, B, AB, BA,…). Predicting either mean sampling realizations of the Gaussian process or using the posterior mean of the Gaussian process (if the number of GP realizations is set to 1).

number_gp_realizations#

number of Gaussian process realizations

Type:

int

gp_model#

Gaussian process model

Type:

Model

seed_posterior_samples#

seed for posterior samples

Type:

int

classmethod from_config_create(method_options, gp_model)[source]#

Create estimator from problem description.

Parameters:
  • method_options (dict) – dictionary with method options

  • gp_model (Model) – Gaussian process model

Returns:

estimator – SobolIndexEstimator

predict(samples)[source]#

Predict output at Monte-Carlo samples.

Sample realizations of Gaussian process or use the posterior mean of the Gaussian process.

Parameters:

samples (xr.Array) – Monte-Carlo samples

Returns:

prediction (xr.Array) – predictions

queens.iterators.sobol_index_gp_uncertainty.sampler module#

Helper class for generating Monte-Carlo samples for Sobol indices.

class Sampler(parameter_names, number_monte_carlo_samples, seed_monte_carlo, calculate_second_order, parameters, sampling_approach)[source]#

Bases: object

Sampler class.

Draw Monte-Carlo samples and generate sample matrices A, B, AB, BA following

Saltelli, A., et al. ‘Variance Based Sensitivity Analysis of Model Output. Design and Estimator for the Total Sensitivity Index’. Computer Physics Communications 181, no. 2 (1 February 2010): 259–270. https://doi.org/10.1016/j.cpc.2009.09.018.

Saltelli, A., ed. Global Sensitivity Analysis: The Primer. Chichester, England; Hoboken, NJ: John Wiley & Sons, Ltd., 2008. https://doi.org/10.1002/9780470725184.

number_parameters#

number of input space dimensions

Type:

int

number_monte_carlo_samples#

number of Monte-Carlo samples

Type:

int

sampling_approach#

sampling approach (pseudo-random or quasi-random)

Type:

string

calculate_second_order#

true if second-order indices are calculated

Type:

bool

parameters#

information about distribution of random variables

Type:

list

parameter_names#

list of names of input parameters

Type:

list

seed_monte_carlo#

seed for random samples

Type:

int

classmethod from_config_create(method_options, parameter_names, parameters)[source]#

Create sampler from problem description.

Parameters:
  • method_options (dict) – dictionary with method options

  • parameter_names (list) – list of parameter names

  • parameters (list) – information about distribution of random variables

Returns:

sampler – Sampler object

sample()[source]#

Generate sample matrices.

Generate sample matrices A, B, AB, BA following

Saltelli, A., et al. ‘Variance Based Sensitivity Analysis of Model Output. Design and Estimator for the Total Sensitivity Index’. Computer Physics Communications 181, no. 2 (1 February 2010): 259–270. https://doi.org/10.1016/j.cpc.2009.09.018.

Saltelli, A., ed. Global Sensitivity Analysis: The Primer. Chichester, England; Hoboken, NJ: John Wiley & Sons, Ltd., 2008. https://doi.org/10.1002/9780470725184.

sample_matrix_a: sample matrix A sample_matrix_b: sample matrix B sample_matrix_ab: separated from A by only change in X_i; from B by change in X_{~i} sample_matrix_ba: separated from B by only change in X_i; from A by change in X_{~i}

Returns:

samples (xr.Array) – Monte-Carlo samples

class ThirdOrderSampler(parameter_names, number_monte_carlo_samples, seed_monte_carlo, calculate_second_order, parameters, sampling_approach, calculate_third_order, third_order_parameters)[source]#

Bases: Sampler

ThirdOrderSampler class.

Draw Monte-Carlo samples and generate sample matrices following

Saltelli, A., et al. ‘Variance Based Sensitivity Analysis of Model Output. Design and Estimator for the Total Sensitivity Index’. Computer Physics Communications 181, no. 2 (1 February 2010): 259–270. https://doi.org/10.1016/j.cpc.2009.09.018.

Saltelli, A., ed. Global Sensitivity Analysis: The Primer. Chichester, England; Hoboken, NJ: John Wiley & Sons, Ltd., 2008. https://doi.org/10.1002/9780470725184.

calculate_third_order#

true if third-order indices only are calculated

Type:

bool

third_order_parameters#

list of parameter combination for third-order index

Type:

list

classmethod from_config_create(method_options, parameter_names, parameters)[source]#

Create third-order sampler from problem description.

Parameters:
  • method_options (dict) – dictionary with method options

  • parameter_names (list) – list of parameter names

  • parameters (list) – information about distribution of random variables

Returns:

sampler – Sampler object

sample()[source]#

Generate sample matrices.

Generate sample matrices A, B, AB, BA, AB_ijk following

Saltelli, A., et al. ‘Variance Based Sensitivity Analysis of Model Output. Design and Estimator for the Total Sensitivity Index’. Computer Physics Communications 181, no. 2 (1 February 2010): 259–270. https://doi.org/10.1016/j.cpc.2009.09.018.

Saltelli, A., ed. Global Sensitivity Analysis: The Primer. Chichester, England; Hoboken, NJ: John Wiley & Sons, Ltd., 2008. https://doi.org/10.1002/9780470725184.

sample_matrix_a: sample matrix A sample_matrix_b: sample matrix B sample_matrix_ab: separated from A by only change in X_i; from B by change in X_{~i} sample_matrix_ba: separated from B by only change in X_i; from A by change in X_{~i} sample_matrix_ab_ijk: separated from A by a change in X_i, X_j and X_k

Returns:

samples (xr.Array) – Monte-Carlo sample matrices

queens.iterators.sobol_index_gp_uncertainty.statistics module#

Helper classes for statistics of Sobol index estimates.

class StatisticsSecondOrderEstimates(parameter_names, number_gp_realizations, number_bootstrap_samples)[source]#

Bases: StatisticsSobolIndexEstimates

Statistics class for second-order Sobol index estimates.

Calculate statistics for the second-order Sobol index estimates, including mean, variances and confidence intervals of the estimates.

evaluate(estimates, conf_level=0.95)[source]#

Evaluate statistics.

Parameters:
  • estimates (xr.DataArray) – first-order index estimates

  • conf_level (float) – confidence level (default: 0.95)

class StatisticsSobolIndexEstimates(parameter_names, number_gp_realizations, number_bootstrap_samples)[source]#

Bases: object

Statistics class for Sobol index estimates.

Calculate statistics for the first- or total order Sobol index estimates, including mean, variances and confidence intervals of the Sobol index estimates.

Based on Le Gratiet, Loic, Claire Cannamela, and Bertrand Iooss. ‘A Bayesian Approach for Global Sensitivity Analysis of (Multifidelity) Computer Codes’. SIAM/ASA Journal on Uncertainty Quantification 2, no. 1 (1 January 2014): 336–63. https://doi.org/10.1137/130926869.

number_bootstrap_samples#

number of bootstrap samples

Type:

int

number_parameters#

number of input parameter space dimensions

Type:

int

number_gp_realizations#

number of Gaussian process realizations

Type:

int

parameter_names#

list of parameter names

Type:

list

evaluate(estimates, conf_level=0.95)[source]#

Evaluate statistics.

Parameters:
  • estimates (xr.DataArray) – Sobol index estimates

  • conf_level (float) – confidence level (default: 0.95)

classmethod from_config_create(method_options, parameter_names)[source]#

Create statistics from problem description.

Parameters:
  • method_options (dict) – dictionary with method options

  • parameter_names (list) – list of parameter names

Returns:

statistics – Statistics object

class StatisticsThirdOrderSobolIndexEstimates(parameter_names, number_gp_realizations, number_bootstrap_samples, third_order_parameters)[source]#

Bases: StatisticsSobolIndexEstimates

Statistics class for third-order Sobol index estimates.

Calculate statistics for the third-order Sobol index estimates, including mean, variances and confidence intervals of the estimates.

third_order_parameters#

list of parameter combination for third-order index

Type:

list

evaluate(estimates, conf_level=0.95)[source]#

Evaluate statistics.

Parameters:
  • estimates (xr.DataArray) – Sobol index estimates

  • conf_level (float) – confidence level (default: 0.95)

classmethod from_config_create(method_options, parameter_names)[source]#

Create statistics from problem description.

Parameters:
  • method_options (dict) – dictionary with method options

  • parameter_names (list) – list of parameter names

Returns:

statistics – StatisticsThirdOrder object

queens.iterators.sobol_index_gp_uncertainty.utils_estimate_indices module#

Utils for Sobol index estimation.

All functions below are independent functions so that they can be used for parallel computations with multiprocessing.

Important: Do not use XArrays in parallel processes as they are very slow!

bootstrap(prediction, bootstrap_indices)[source]#

Bootstrap samples.

Parameters:
  • prediction (ndarray) – realizations of Gaussian process

  • bootstrap_indices (ndarray) – bootstrap indices

Returns:

current_bootstrap_sample (ndarray) – current bootstrap sample

calculate_indices_first_total_order(prediction, bootstrap_idx, input_dim, number_bootstrap_samples, first_order_estimator)[source]#

Estimate first and total-order Sobol indices.

Parameters:
  • prediction (ndarray) – realizations of Gaussian process

  • bootstrap_idx (ndarray) – bootstrap indices

  • input_dim (int) – input-parameter index

  • number_bootstrap_samples (int) – number of bootstrap samples

  • first_order_estimator (str) – estimator for first-order indices

Returns:
  • estimates_first_order (ndarray) – estimates of first-order Sobol index

  • estimates_total_order (ndarray) – estimates of total-order Sobol index

calculate_indices_second_order_gp_mean(prediction, bootstrap_indices, input_dim_i, number_parameters, first_order_estimator)[source]#

Estimate first, second and total-order Sobol indices.

Based on Gaussian process mean and parallelized over bootstrapping samples.

Parameters:
  • prediction (ndarray) – prediction

  • bootstrap_indices (ndarray) – bootstrap indices

  • input_dim_i (int) – input-parameter index

  • number_parameters (int) – number of input-space dimensions

  • first_order_estimator (str) – estimator for first-order indices

Returns:
  • estimates_first_order (ndarray) – estimates of first-order Sobol index

  • estimates_second_order (ndarray) – estimates of second-order Sobol index

  • estimates_total_order (ndarray) – estimates of total-order Sobol index

calculate_indices_second_order_gp_realizations(prediction, bootstrap_indices, input_dim_i, number_bootstrap_samples, number_parameters, first_order_estimator)[source]#

Estimate first, second and total-order Sobol indices.

Based on Gaussian process realizations and parallelized over those realizations.

Parameters:
  • prediction (ndarray) – realizations of Gaussian process

  • bootstrap_indices (ndarray) – bootstrap indices

  • input_dim_i (int) – input-parameter index

  • number_bootstrap_samples (int) – number of bootstrap samples

  • number_parameters (int) – number of input-space dimensions

  • first_order_estimator (str) – estimator for first-order indices

Returns:
  • estimates_first_order (ndarray) – estimates of first-order Sobol index

  • estimates_second_order (ndarray) – estimates of second-order Sobol index

  • estimates_total_order (ndarray) – estimates of total-order Sobol index

calculate_indices_third_order(prediction, bootstrap_indices, number_boostrap_samples, number_parameters, first_order_estimator)[source]#

Estimate third-order Sobol indices.

Based on Gaussian process realizations and parallelized over those realizations.

Parameters:
  • prediction (ndarray) – realizations of Gaussian process

  • bootstrap_indices (ndarray) – bootstrap indices

  • number_boostrap_samples (int) – number of bootstrap samples

  • number_parameters (int) – number of input-space dimensions

  • first_order_estimator (str) – estimator for first-order indices

Returns:

estimates_third_order (ndarray) – estimates for third-order Sobol index