.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_meta_modeling/polynomial_chaos_metamodel/plot_chaos_ishigami_grouped_indices.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_meta_modeling_polynomial_chaos_metamodel_plot_chaos_ishigami_grouped_indices.py: Compute grouped indices for the Ishigami function ================================================= .. GENERATED FROM PYTHON SOURCE LINES 6-7 In this example, we compute grouped Sobol' indices for the :ref:`Ishigami function `. .. GENERATED FROM PYTHON SOURCE LINES 10-18 .. code-block:: default from openturns.usecases import ishigami_function as ishigami_function import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt from math import pi import openturns.viewer as otv ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 19-20 We load the Ishigami test function from usecases module : .. GENERATED FROM PYTHON SOURCE LINES 20-22 .. code-block:: default im = ishigami_function.IshigamiModel() .. GENERATED FROM PYTHON SOURCE LINES 23-25 The `IshigamiModel` data class contains the input distribution :math:`X=(X_1, X_2, X_3)` in `im.distributionX` and the Ishigami function in `im.model`. We also have access to the input variable names with .. GENERATED FROM PYTHON SOURCE LINES 25-28 .. code-block:: default input_names = im.distributionX.getDescription() .. GENERATED FROM PYTHON SOURCE LINES 29-30 Create a training sample .. GENERATED FROM PYTHON SOURCE LINES 32-36 .. code-block:: default N = 100 inputTrain = im.distributionX.getSample(N) outputTrain = im.model(inputTrain) .. GENERATED FROM PYTHON SOURCE LINES 37-38 Create the chaos. .. GENERATED FROM PYTHON SOURCE LINES 40-52 .. code-block:: default multivariateBasis = ot.OrthogonalProductPolynomialFactory( [im.X1, im.X2, im.X3]) selectionAlgorithm = ot.LeastSquaresMetaModelSelectionFactory() projectionStrategy = ot.LeastSquaresStrategy( inputTrain, outputTrain, selectionAlgorithm) totalDegree = 8 enumfunc = multivariateBasis.getEnumerateFunction() P = enumfunc.getStrataCumulatedCardinal(totalDegree) adaptiveStrategy = ot.FixedStrategy(multivariateBasis, P) chaosalgo = ot.FunctionalChaosAlgorithm( inputTrain, outputTrain, im.distributionX, adaptiveStrategy, projectionStrategy) .. GENERATED FROM PYTHON SOURCE LINES 53-57 .. code-block:: default chaosalgo.run() result = chaosalgo.getResult() metamodel = result.getMetaModel() .. GENERATED FROM PYTHON SOURCE LINES 58-59 Print Sobol' indices .. GENERATED FROM PYTHON SOURCE LINES 61-64 .. code-block:: default chaosSI = ot.FunctionalChaosSobolIndices(result) print(chaosSI.summary()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none input dimension: 3 output dimension: 1 basis size: 26 mean: [3.50739] std-dev: [3.70413] ------------------------------------------------------------ Index | Multi-indice | Part of variance ------------------------------------------------------------ 7 | [0,4,0] | 0.274425 1 | [1,0,0] | 0.191936 6 | [1,0,2] | 0.135811 13 | [0,6,0] | 0.134001 5 | [3,0,0] | 0.122952 10 | [3,0,2] | 0.0856397 3 | [0,2,0] | 0.0237185 11 | [1,0,4] | 0.0112027 ------------------------------------------------------------ ------------------------------------------------------------ Component | Sobol index | Sobol total index ------------------------------------------------------------ 0 | 0.31752 | 0.559269 1 | 0.440685 | 0.440794 2 | 1.87833e-05 | 0.241742 ------------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 65-66 We compute the first order indice of the group [0,1]. .. GENERATED FROM PYTHON SOURCE LINES 68-70 .. code-block:: default chaosSI.getSobolGroupedIndex([0, 1]) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.7582578489711685 .. GENERATED FROM PYTHON SOURCE LINES 71-78 This group collects all the multi-indices containing variables only in this group, including interactions within the group (by decreasing order of significance): * [0,4,0] : 0.279938 * [1,0,0] : 0.190322 * [0,6,0] : 0.130033 * [3,0,0] : 0.12058 * [0,2,0] : 0.0250262 .. GENERATED FROM PYTHON SOURCE LINES 80-82 .. code-block:: default 0.279938 + 0.190322 + 0.130033 + 0.12058 + 0.0250262 .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.7458992 .. GENERATED FROM PYTHON SOURCE LINES 83-84 The difference between the previous sum and the output of `getSobolGroupedIndex` is lower than 0.01, which is the threshold used by the `summary` method. .. GENERATED FROM PYTHON SOURCE LINES 86-87 We compute the total order indice of the group [1,2]. .. GENERATED FROM PYTHON SOURCE LINES 89-91 .. code-block:: default chaosSI.getSobolGroupedTotalIndex([1, 2]) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.6824803087795113 .. GENERATED FROM PYTHON SOURCE LINES 92-100 This group collects all the multi-indices containing variables in this group, including interactions with variables outside the group: * [0,4,0] : 0.279938 * [1,0,2] : 0.136823 * [0,6,0] : 0.130033 * [3,0,2] : 0.0837457 * [0,2,0] : 0.0250262 * [1,0,4] : 0.0111867 .. GENERATED FROM PYTHON SOURCE LINES 102-103 .. code-block:: default 0.279938 + 0.136823 + 0.130033 + 0.0837457 + 0.0250262 + 0.0111867 .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.6667526 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.026 seconds) .. _sphx_glr_download_auto_meta_modeling_polynomial_chaos_metamodel_plot_chaos_ishigami_grouped_indices.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_chaos_ishigami_grouped_indices.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_chaos_ishigami_grouped_indices.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_