.. 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 :ref:`Go to the end ` 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 7-8 In this example, we compute grouped Sobol' indices for the :ref:`Ishigami function `. .. GENERATED FROM PYTHON SOURCE LINES 11-15 .. code-block:: Python from openturns.usecases import ishigami_function import openturns as ot .. GENERATED FROM PYTHON SOURCE LINES 16-17 We load the Ishigami test function from usecases module: .. GENERATED FROM PYTHON SOURCE LINES 17-19 .. code-block:: Python im = ishigami_function.IshigamiModel() .. GENERATED FROM PYTHON SOURCE LINES 20-23 The `IshigamiModel` data class contains the input distribution of the random vector :math:`\vect{X}=\Tr{(X_1, X_2, X_3)}` in `im.inputDistribution` and the Ishigami function in `im.model`. We also have access to the input variable names with: .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python input_names = im.inputDistribution.getDescription() .. GENERATED FROM PYTHON SOURCE LINES 27-28 Create a training sample. .. GENERATED FROM PYTHON SOURCE LINES 30-34 .. code-block:: Python N = 100 inputTrain = im.inputDistribution.getSample(N) outputTrain = im.model(inputTrain) .. GENERATED FROM PYTHON SOURCE LINES 35-36 Create the chaos. .. GENERATED FROM PYTHON SOURCE LINES 38-51 .. code-block:: Python 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.inputDistribution, adaptiveStrategy, projectionStrategy ) .. GENERATED FROM PYTHON SOURCE LINES 52-56 .. code-block:: Python chaosalgo.run() result = chaosalgo.getResult() metamodel = result.getMetaModel() .. GENERATED FROM PYTHON SOURCE LINES 57-58 Print Sobol' indices. .. GENERATED FROM PYTHON SOURCE LINES 60-63 .. code-block:: Python chaosSI = ot.FunctionalChaosSobolIndices(result) chaosSI .. raw:: html
FunctionalChaosSobolIndices
  • input dimension: 3
  • output dimension: 1
  • basis size: 26
  • mean: [3.50804]
  • std-dev: [3.70043]
Input Variable Sobol' index Total index
0 X1 0.313447 0.555260
1 X2 0.444616 0.444775
2 X3 0.000057 0.241886
Index Multi-index Part of variance
7 [0,4,0] 0.279938
1 [1,0,0] 0.190322
6 [1,0,2] 0.136823
15 [0,6,0] 0.130033
5 [3,0,0] 0.120580
11 [3,0,2] 0.083746
3 [0,2,0] 0.025026
12 [1,0,4] 0.011187


.. GENERATED FROM PYTHON SOURCE LINES 64-65 We compute the first order indice of the group `[0,1]` . .. GENERATED FROM PYTHON SOURCE LINES 67-69 .. code-block:: Python chaosSI.getSobolGroupedIndex([0, 1]) .. rst-class:: sphx-glr-script-out .. code-block:: none 0.7581141221738299 .. GENERATED FROM PYTHON SOURCE LINES 70-77 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 79-81 .. code-block:: Python 0.279938 + 0.190322 + 0.130033 + 0.12058 + 0.0250262 .. rst-class:: sphx-glr-script-out .. code-block:: none 0.7458992 .. GENERATED FROM PYTHON SOURCE LINES 82-83 The difference between the previous sum and the output of `getSobolGroupedIndex` is lower than 0.01, which is the threshold used by the `__str__` method. .. GENERATED FROM PYTHON SOURCE LINES 85-86 We compute the total order indice of the group [1,2]. .. GENERATED FROM PYTHON SOURCE LINES 88-90 .. code-block:: Python chaosSI.getSobolGroupedTotalIndex([1, 2]) .. rst-class:: sphx-glr-script-out .. code-block:: none 0.6865529054018148 .. GENERATED FROM PYTHON SOURCE LINES 91-99 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 101-102 .. code-block:: Python 0.279938 + 0.136823 + 0.130033 + 0.0837457 + 0.0250262 + 0.0111867 .. rst-class:: sphx-glr-script-out .. code-block:: none 0.6667526 .. _sphx_glr_download_auto_meta_modeling_polynomial_chaos_metamodel_plot_chaos_ishigami_grouped_indices.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_chaos_ishigami_grouped_indices.ipynb ` .. 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-zip :download:`Download zipped: plot_chaos_ishigami_grouped_indices.zip `