.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/sensitivity/generalised_sobol/generalised_sobol_multioutput.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_sensitivity_generalised_sobol_generalised_sobol_multioutput.py: Toy multioutput function ============================================== In this example, we demonstrate the computation of the Generalised Sobol indices using the toy example in [1]_. .. math:: Y = f (X_{1}, X_{2}) := \left(\begin{array}{c} X_{1}+X_{2}+X_{1} X_{2} \\ 2 X_{1}+3 X_{1} X_{2}+X_{2} \end{array}\right) .. math:: \text{case 1: } X_1, X_2 \sim \mathcal{N}(0, 1) .. math:: \text{case 2: } X_1, X_2 \sim \mathcal{U}(0, 1) .. [1] Gamboa, F., Janon, A., Klein, T., & Lagnoux, A. (2014). Sensitivity analysis for multidimensional and functional outputs. Electronic Journal of Statistics, 8(1), 575-603. .. GENERATED FROM PYTHON SOURCE LINES 26-35 .. code-block:: default from UQpy.run_model.RunModel import RunModel from UQpy.run_model.model_execution.PythonModel import PythonModel from UQpy.distributions import Uniform, Normal from UQpy.distributions.collection.JointIndependent import JointIndependent from UQpy.sensitivity.GeneralisedSobolSensitivity import GeneralisedSobolSensitivity from UQpy.sensitivity.PostProcess import * np.random.seed(123) .. GENERATED FROM PYTHON SOURCE LINES 36-37 **Define the model and input distributions** .. GENERATED FROM PYTHON SOURCE LINES 37-51 .. code-block:: default # Create Model object model = PythonModel( model_script="local_multioutput.py", model_object_name="evaluate", var_names=[r"X_1$", r"X_2"], delete_files=True, ) runmodel_obj = RunModel(model=model) # Define distribution object dist_object_1 = JointIndependent([Normal(0, 1)] * 2) .. GENERATED FROM PYTHON SOURCE LINES 52-53 **Compute generalised Sobol indices** .. GENERATED FROM PYTHON SOURCE LINES 55-61 .. code-block:: default SA = GeneralisedSobolSensitivity(runmodel_obj, dist_object_1) SA.run( n_samples=20_000, confidence_level=0.95, n_bootstrap_samples=5_00 ) .. GENERATED FROM PYTHON SOURCE LINES 62-71 **First order Generalised Sobol indices** Expected generalised Sobol indices: Gaussian case :math:`GS_1` = 0.2941 :math:`GS_2` = 0.1179 .. GENERATED FROM PYTHON SOURCE LINES 73-83 .. code-block:: default SA.generalized_first_order_indices # **Plot the first order sensitivity indices** fig1, ax1 = plot_sensitivity_index( SA.generalized_first_order_indices[:, 0], confidence_interval=SA.first_order_confidence_interval, plot_title="First order Generalised Sobol indices", color="C0", ) .. GENERATED FROM PYTHON SOURCE LINES 84-97 .. code-block:: default SA.generalized_total_order_indices # **Plot the first and total order sensitivity indices** fig2, ax2 = plot_index_comparison( SA.generalized_first_order_indices[:, 0], SA.generalized_total_order_indices[:, 0], confidence_interval_1=SA.first_order_confidence_interval, confidence_interval_2=SA.total_order_confidence_interval, label_1="First order", label_2="Total order", plot_title="First and Total order Generalised Sobol indices", ) .. GENERATED FROM PYTHON SOURCE LINES 98-99 **Compute generalised Sobol indices** .. GENERATED FROM PYTHON SOURCE LINES 101-109 .. code-block:: default dist_object_2 = JointIndependent([Uniform(0, 1)] * 2) SA = GeneralisedSobolSensitivity(runmodel_obj, dist_object_2) SA.run( n_samples=20_000, confidence_level=0.95, n_bootstrap_samples=5_00 ) .. GENERATED FROM PYTHON SOURCE LINES 110-119 **First order Generalised Sobol indices** Expected generalised Sobol indices: Uniform case :math:`GS_1` = 0.6084 :math:`GS_2` = 0.3566 .. GENERATED FROM PYTHON SOURCE LINES 121-131 .. code-block:: default SA.generalized_first_order_indices # **Plot the first order sensitivity indices** fig3, ax3 = plot_sensitivity_index( SA.generalized_first_order_indices[:, 0], confidence_interval=SA.first_order_confidence_interval, plot_title="First order Generalised Sobol indices", color="C0", ) .. GENERATED FROM PYTHON SOURCE LINES 132-144 .. code-block:: default SA.total_order_confidence_interval # **Plot the first and total order sensitivity indices** fig4, ax4 = plot_index_comparison( SA.generalized_first_order_indices[:, 0], SA.total_order_confidence_interval[:, 0], confidence_interval_1=SA.first_order_confidence_interval, confidence_interval_2=SA.total_order_confidence_interval, label_1="First order", label_2="Total order", plot_title="First and Total order Generalised Sobol indices", ) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_sensitivity_generalised_sobol_generalised_sobol_multioutput.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/SURGroup/UQpy/master?urlpath=lab/tree/notebooks/auto_examples/sensitivity/generalised_sobol/generalised_sobol_multioutput.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: generalised_sobol_multioutput.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: generalised_sobol_multioutput.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_