Note
Go to the end to download the full example code or to run this example in your browser via Binder
Ishigami function
The ishigami function is a non-linear, non-monotonic function that is commonly used to benchmark uncertainty and senstivity analysis methods.
First order Sobol indices
Total order Sobol indices
import numpy as np
from UQpy.run_model.RunModel import RunModel
from UQpy.run_model.model_execution.PythonModel import PythonModel
from UQpy.distributions import Uniform
from UQpy.distributions.collection.JointIndependent import JointIndependent
from UQpy.sensitivity.SobolSensitivity import SobolSensitivity
from UQpy.sensitivity.PostProcess import *
np.random.seed(123)
Define the model and input distributions
Create Model object
Compute Sobol indices
SA = SobolSensitivity(runmodel_obj, dist_object)
SA.run(n_samples=100_000, n_bootstrap_samples=100)
First order Sobol indices
Expected first order Sobol indices:
\(S_1\) = 0.3139
\(S_2\) = 0.4424
\(S_3\) = 0.0
SA.first_order_indices
Total order Sobol indices
Expected total order Sobol indices:
\(S_{T_1}\) = 0.55758886
\(S_{T_2}\) = 0.44241114
\(S_{T_3}\) = 0.24368366
SA.total_order_indices
Confidence intervals for first order Sobol indices
SA.first_order_confidence_interval
Confidence intervals for total order Sobol indices
SA.total_order_confidence_interval
Plot the first order sensitivity indices
fig1, ax1 = plot_sensitivity_index(
SA.first_order_indices[:, 0],
confidence_interval=SA.first_order_confidence_interval,
plot_title="First order Sobol indices",
variable_names=["$X_1$", "$X_2$", "$X_3$"],
color="C0",
)
Plot the first and total order sensitivity indices
fig2, ax2 = plot_index_comparison(
SA.first_order_indices[:, 0],
SA.total_order_indices[:, 0],
confidence_interval_1=SA.first_order_confidence_interval,
confidence_interval_2=SA.total_order_confidence_interval,
label_1="First order Sobol indices",
label_2="Total order Sobol indices",
plot_title="First and Total order Sobol indices",
variable_names=["$X_1$", "$X_2$", "$X_3$"],
)
Total running time of the script: ( 0 minutes 0.000 seconds)