.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_reliability_sensitivity/sensitivity_analysis/plot_sensitivity_rank_sobol.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_reliability_sensitivity_sensitivity_analysis_plot_sensitivity_rank_sobol.py: Sobol' sensitivity indices using rank-based algorithm ===================================================== .. GENERATED FROM PYTHON SOURCE LINES 5-11 .. code-block:: Python import openturns as ot import openturns.experimental as otexp import openturns.viewer as viewer from openturns.usecases import ishigami_function .. GENERATED FROM PYTHON SOURCE LINES 12-15 In this example we are going to compute global sensitivity indices in a data driven framework. For that purpose, we are using the rank-based algorithm which provides the first order Sobol' indices. We present the method on the :ref:`Ishigami function`. .. GENERATED FROM PYTHON SOURCE LINES 15-18 .. code-block:: Python ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 19-23 Definition of the model ----------------------- We load the model from the usecases module. .. GENERATED FROM PYTHON SOURCE LINES 23-25 .. code-block:: Python im = ishigami_function.IshigamiModel() .. GENERATED FROM PYTHON SOURCE LINES 26-27 We generate an input sample of size 500 (and dimension 3). .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: Python size = 500 ot.RandomGenerator.SetSeed(10) X = im.distributionX.getSample(size) .. GENERATED FROM PYTHON SOURCE LINES 32-33 We compute the output by applying the Ishigami model to the input sample. .. GENERATED FROM PYTHON SOURCE LINES 33-35 .. code-block:: Python Y = im.model(X) .. GENERATED FROM PYTHON SOURCE LINES 36-37 Estimate Sobol' first order indices via rank-based algorithm. .. GENERATED FROM PYTHON SOURCE LINES 37-41 .. code-block:: Python mySobol = otexp.RankSobolSensitivityAlgorithm(X, Y) indices = mySobol.getFirstOrderIndices() print("First order indices:", indices) .. rst-class:: sphx-glr-script-out .. code-block:: none First order indices: [0.29008,0.421935,0.0856989] .. GENERATED FROM PYTHON SOURCE LINES 42-45 Draw Sobol' indices. Options for confidence interval estimation can be defined. .. GENERATED FROM PYTHON SOURCE LINES 45-50 .. code-block:: Python ot.ResourceMap.SetAsUnsignedInteger("SobolIndicesAlgorithm-DefaultBootstrapSize", 200) ot.ResourceMap.SetAsScalar( "RankSobolSensitivityAlgorithm-DefaultBootstrapSampleRatio", 0.85 ) .. GENERATED FROM PYTHON SOURCE LINES 51-52 if `SobolIndicesAlgorithm-DefaultBootstrapSize` > 1, the draw() method will call bootstrap method to compute the confidence intervals. .. GENERATED FROM PYTHON SOURCE LINES 52-59 .. code-block:: Python graph = mySobol.draw() graph.setTitle("Sobol' indices") view = viewer.View(graph) print("confidence intervals:", mySobol.getFirstOrderIndicesInterval()) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_rank_sobol_001.png :alt: Sobol' indices :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_rank_sobol_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none confidence intervals: [0.238895, 0.337643] [0.381658, 0.485514] [-0.030505, 0.151549] .. GENERATED FROM PYTHON SOURCE LINES 60-61 It is possible that Sobol' indices estimates take negative values, that is inconsistent with the theory. Therefore, a larger number of samples is required to get consistent indices. .. _sphx_glr_download_auto_reliability_sensitivity_sensitivity_analysis_plot_sensitivity_rank_sobol.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sensitivity_rank_sobol.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sensitivity_rank_sobol.py `