.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/sensitivity/cramer_von_mises/cvm_exponential.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_cramer_von_mises_cvm_exponential.py: Exponential function ============================================== The exponential function was used in [1]_ to demonstrate the Cramér-von Mises indices. .. math:: f(x) := \exp(x_1 + 2x_2), \quad x_1, x_2 \sim \mathcal{N}(0, 1) .. [1] Gamboa, F., Klein, T., & Lagnoux, A. (2018). Sensitivity Analysis Based on Cramér-von Mises Distance. SIAM/ASA Journal on Uncertainty Quantification, 6(2), 522-548. doi:10.1137/15M1025621. (`Link `_) .. GENERATED FROM PYTHON SOURCE LINES 19-28 .. code-block:: default from UQpy.run_model.RunModel import RunModel from UQpy.run_model.model_execution.PythonModel import PythonModel from UQpy.distributions import Normal from UQpy.distributions.collection.JointIndependent import JointIndependent from UQpy.sensitivity.CramerVonMisesSensitivity import CramerVonMisesSensitivity as cvm from UQpy.sensitivity.PostProcess import * np.random.seed(123) .. GENERATED FROM PYTHON SOURCE LINES 29-30 **Define the model and input distributions** .. GENERATED FROM PYTHON SOURCE LINES 30-44 .. code-block:: default # Create Model object model = PythonModel( model_script="local_exponential.py", model_object_name="evaluate", var_names=[r"$X_1$", "$X_2$"], delete_files=True, ) runmodel_obj = RunModel(model=model) # Define distribution object dist_object = JointIndependent([Normal(0, 1)] * 2) .. GENERATED FROM PYTHON SOURCE LINES 45-46 **Compute Cramér-von Mises indices** .. GENERATED FROM PYTHON SOURCE LINES 48-53 .. code-block:: default SA = cvm(runmodel_obj, dist_object) # Compute CVM indices using the pick and freeze algorithm SA.run(n_samples=20_000, estimate_sobol_indices=True) .. GENERATED FROM PYTHON SOURCE LINES 54-61 **Cramér-von Mises indices** Expected value of the sensitivity indices: :math:`S^1_{CVM} = \frac{6}{\pi} \operatorname{arctan}(2) - 2 \approx 0.1145` :math:`S^2_{CVM} = \frac{6}{\pi} \operatorname{arctan}(\sqrt{19}) - 2 \approx 0.5693` .. GENERATED FROM PYTHON SOURCE LINES 63-72 .. code-block:: default SA.first_order_CramerVonMises_indices # **Plot the CVM indices** fig1, ax1 = plot_sensitivity_index( SA.first_order_CramerVonMises_indices[:, 0], plot_title="Cramér-von Mises indices", color="C4", ) .. GENERATED FROM PYTHON SOURCE LINES 73-80 **Estimated first order Sobol indices** Expected first order Sobol indices: :math:`S_1` = 0.0118 :math:`S_2` = 0.3738 .. GENERATED FROM PYTHON SOURCE LINES 82-91 .. code-block:: default SA.first_order_sobol_indices # **Plot the first order Sobol indices** fig2, ax2 = plot_sensitivity_index( SA.first_order_sobol_indices[:, 0], plot_title="First order Sobol indices", color="C0", ) .. GENERATED FROM PYTHON SOURCE LINES 92-93 **Estimated total order Sobol indices** .. GENERATED FROM PYTHON SOURCE LINES 95-105 .. code-block:: default SA.total_order_sobol_indices # **Plot the first and total order sensitivity indices** fig3, ax3 = plot_index_comparison( SA.first_order_sobol_indices[:, 0], SA.total_order_sobol_indices[:, 0], label_1="First order Sobol indices", label_2="Total order Sobol indices", plot_title="First and Total order Sobol indices", ) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_sensitivity_cramer_von_mises_cvm_exponential.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/cramer_von_mises/cvm_exponential.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cvm_exponential.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cvm_exponential.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_