.. 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_reliability_sensitivity_sensitivity_analysis_plot_sensitivity_sobol.py: Estimate Sobol' indices for the Ishigami function by a sampling method: a quick start guide to sensitivity analysis =================================================================================================================== In this example, we estimate the Sobol' indices for the :ref:Ishigami function  by sampling methods. Introduction ------------ In this example we are going to quantify the correlation between the input variables and the output variable of a model thanks to Sobol indices. Sobol indices are designed to evaluate the importance of a single variable or a specific set of variables. Here the Sobol indices are estimated by sampling from the distributions of the input variables and propagating uncertainty through a function. In theory, Sobol indices range from 0 to 1; the closer an index value is to 1, the better the associated input variable explains the function output. Let us denote by :math:d the input dimension of the model. Sobol' indices can be computed at different orders. * First order indices evaluate the importance of one input variable at a time. * Total indices give the relative importance of one input variable and all its interactions with other variables. Alternatively, they can be viewed as measuring how much wriggle room remains to the output when all but one input variables are fixed. * In general, we are only interested in first order and total Sobol' indices. There are situations, however, where we want to estimate interactions. Second order indices evaluate the importance of every pair of input variables. The number of second order indices is: .. math:: \binom{d}{2} = \frac{d \times \left( d-1\right)}{2}. In practice, when the number of input variables is not small (say, when :math:d>5), then the number of second order indices is too large to be easily analyzed. In these situations, we limit the analysis to the first order and total Sobol' indices. Define the model ---------------- .. code-block:: default import openturns as ot import numpy as np import pylab as pl import openturns.viewer import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) We load the Ishigami model from the usecases model : .. code-block:: default from openturns.usecases import ishigami_function im = ishigami_function.IshigamiModel() 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 .. code-block:: default input_names = im.distributionX.getDescription() Draw the function ----------------- .. code-block:: default n = 10000 sampleX = im.distributionX.getSample(n) sampleY = im.model(sampleX) .. code-block:: default def plotXvsY(sampleX, sampleY, figsize=(15,3)): dimX = sampleX.getDimension() inputdescr = sampleX.getDescription() fig = pl.figure(figsize=figsize) for i in range(dimX): ax = fig.add_subplot(1, dimX, i+1) graph = ot.Graph('', inputdescr[i], 'Y', True, '') cloud = ot.Cloud(sampleX[:,i],sampleY) graph.add(cloud) _ = ot.viewer.View(graph, figure=fig, axes=[ax]) return fig plotXvsY(sampleX, sampleY, figsize=(10,4)); .. image:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_sobol_001.png :alt: plot sensitivity sobol :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none