.. 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_wingweight.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_wingweight.py: Example of sensitivity analyses on the wing weight model ========================================================= .. GENERATED FROM PYTHON SOURCE LINES 6-19 This example is a brief overview of the use of the most usual sensitivity analysis techniques and how to call them: - PCC: Partial Correlation Coefficients - PRCC: Partial Rank Correlation Coefficients - SRC: Standard Regression Coefficients - SRRC: Standard Rank Regression Coefficients - Pearson coefficients - Spearman coefficients - Taylor expansion importance factors - Sobol' indices - HSIC : Hilbert-Schmidt Independence Criterion We present the methods on the :ref:`WingWeight function` and use the same notations. .. GENERATED FROM PYTHON SOURCE LINES 22-28 Definition of the model ----------------------- We load the model from the usecases module. .. GENERATED FROM PYTHON SOURCE LINES 28-37 .. code-block:: Python import openturns as ot import openturns.viewer as otv from openturns.usecases.wingweight_function import WingWeightModel from matplotlib import pylab as plt import numpy as np ot.Log.Show(ot.Log.NONE) m = WingWeightModel() .. GENERATED FROM PYTHON SOURCE LINES 38-45 Cross cuts of the function -------------------------- Let's have a look on 2D cross cuts of the wing weight function. For each 2D cross cut, the other variables are fixed to the input distribution mean values. This graph allows one to have a first idea of the variations of the function in pair of dimensions. The colors of each contour plot are comparable. The number of contour levels are related to the amount of variation of the function in the corresponding coordinates. .. GENERATED FROM PYTHON SOURCE LINES 45-93 .. code-block:: Python fig = plt.figure(figsize=(12, 12)) lowerBound = m.distributionX.getRange().getLowerBound() upperBound = m.distributionX.getRange().getUpperBound() # Definition of number of meshes in x and y axes for the 2D cross cut plots nX = 20 nY = 20 for i in range(m.dim): for j in range(i): crossCutIndices = [] crossCutReferencePoint = [] for k in range(m.dim): if k != i and k != j: crossCutIndices.append(k) # Definition of the reference point crossCutReferencePoint.append(m.distributionX.getMean()[k]) # Definition of 2D cross cut function crossCutFunction = ot.ParametricFunction( m.model, crossCutIndices, crossCutReferencePoint ) crossCutLowerBound = [lowerBound[j], lowerBound[i]] crossCutUpperBound = [upperBound[j], upperBound[i]] # Definition of the mesh inputData = ot.Box([nX, nY]).generate() inputData *= ot.Point(crossCutUpperBound) - ot.Point(crossCutLowerBound) inputData += ot.Point(crossCutLowerBound) meshX = np.array(inputData)[:, 0].reshape(nX + 2, nY + 2) meshY = np.array(inputData)[:, 1].reshape(nX + 2, nY + 2) data = crossCutFunction(inputData) meshZ = np.array(data).reshape(nX + 2, nY + 2) levels = [(150 + 3 * i) for i in range(101)] # Creation of the contour index = 1 + i * m.dim + j ax = fig.add_subplot(m.dim, m.dim, index) ax.pcolormesh( meshX, meshY, meshZ, cmap="hsv", vmin=176.0, vmax=363.0, shading="auto" ) ax.set_xticks([]) ax.set_yticks([]) # Creation of axes title if j == 0: ax.set_ylabel(m.distributionX.getDescription()[i]) if i == 9: ax.set_xlabel(m.distributionX.getDescription()[j]) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_001.png :alt: plot sensitivity wingweight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 94-95 We can see that the variables :math:`t_c, N_z, A, W_{dg}` seem to be influent on the wing weight whereas :math:`\Lambda, \ell, q, W_p, W_{fw}` have less influence on the function. .. GENERATED FROM PYTHON SOURCE LINES 97-101 Data generation --------------- We create the input and output data for the estimation of the different sensitivity coefficients and we get the input variables description: .. GENERATED FROM PYTHON SOURCE LINES 101-108 .. code-block:: Python inputNames = m.distributionX.getDescription() size = 500 inputDesign = m.distributionX.getSample(size) outputDesign = m.model(inputDesign) .. GENERATED FROM PYTHON SOURCE LINES 109-111 Let's estimate the PCC, PRCC, SRC, SRRC, Pearson and Spearman coefficients, display and analyze them. We create a :class:`~openturns.CorrelationAnalysis` model. .. GENERATED FROM PYTHON SOURCE LINES 111-114 .. code-block:: Python corr_analysis = ot.CorrelationAnalysis(inputDesign, outputDesign) .. GENERATED FROM PYTHON SOURCE LINES 115-118 PCC coefficients ---------------- We compute here PCC coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 120-123 .. code-block:: Python pcc_indices = corr_analysis.computePCC() print(pcc_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.940186,0.0882968,0.968989,0.0101513,0.115705,0.315289,-0.947166,0.981847,0.917402,0.44622]#10 .. GENERATED FROM PYTHON SOURCE LINES 127-132 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( pcc_indices, inputNames, "PCC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_002.png :alt: PCC coefficients - Wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 133-136 PRCC coefficients ----------------- We compute here PRCC coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 138-141 .. code-block:: Python prcc_indices = corr_analysis.computePRCC() print(prcc_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.8486,0.0649984,0.913677,-0.0206522,0.0858264,0.179864,-0.862092,0.949614,0.816437,0.340957]#10 .. GENERATED FROM PYTHON SOURCE LINES 142-147 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( prcc_indices, inputNames, "PRCC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_003.png :alt: PRCC coefficients - Wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 148-151 SRC coefficients ------------------- We compute here SRC coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 153-156 .. code-block:: Python src_indices = corr_analysis.computeSRC() print(src_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.368479,0.0117622,0.519118,0.00135185,0.0153738,0.043904,-0.391804,0.692999,0.303627,0.0659533]#10 .. GENERATED FROM PYTHON SOURCE LINES 157-162 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( src_indices, inputNames, "SRC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_004.png :alt: SRC coefficients - Wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 163-164 Normalized squared SRC coefficients (coefficients are made to sum to 1) : .. GENERATED FROM PYTHON SOURCE LINES 166-169 .. code-block:: Python squared_src_indices = corr_analysis.computeSquaredSRC(True) print(squared_src_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.119327,0.000121588,0.236833,1.60608e-06,0.000207717,0.00169402,0.134911,0.422061,0.0810197,0.00382282]#10 .. GENERATED FROM PYTHON SOURCE LINES 170-171 And their associated graph: .. GENERATED FROM PYTHON SOURCE LINES 173-178 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( squared_src_indices, inputNames, "Squared SRC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_005.png :alt: Squared SRC coefficients - Wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 182-185 SRRC coefficients -------------------- We compute here SRRC coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 187-190 .. code-block:: Python srrc_indices = corr_analysis.computeSRRC() print(srrc_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.361267,0.0145646,0.501659,-0.00463828,0.0191614,0.0407509,-0.380531,0.683358,0.313877,0.0808765]#10 .. GENERATED FROM PYTHON SOURCE LINES 191-196 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( srrc_indices, inputNames, "SRRC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_006.png :alt: SRRC coefficients - Wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 197-200 Pearson coefficients ----------------------- We compute here the Pearson :math:`\rho` coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 202-205 .. code-block:: Python pearson_correlation = corr_analysis.computePearsonCorrelation() print(pearson_correlation) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.235512,-0.0328824,0.419915,-0.0135446,-0.0692302,0.0434365,-0.379096,0.612647,0.335063,0.0419078]#10 .. GENERATED FROM PYTHON SOURCE LINES 206-212 .. code-block:: Python title_pearson_graph = "Pearson correlation coefficients - Wing weight" graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( pearson_correlation, inputNames, title_pearson_graph ) view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_007.png :alt: Pearson correlation coefficients - Wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_007.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 213-216 Spearman coefficients ----------------------- We compute here the Spearman :math:`\rho_s` coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 218-221 .. code-block:: Python spearman_correlation = corr_analysis.computeSpearmanCorrelation() print(spearman_correlation) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.226962,-0.0274201,0.40528,-0.0187471,-0.0642766,0.0358186,-0.366801,0.605454,0.344385,0.0551515]#10 .. GENERATED FROM PYTHON SOURCE LINES 222-229 .. code-block:: Python title_spearman_graph = "Spearman correlation coefficients - Wing weight" graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( spearman_correlation, inputNames, title_spearman_graph ) view = otv.View(graph) plt.show() .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_008.png :alt: Spearman correlation coefficients - Wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_008.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 230-233 The different computed correlation estimators show that the variables :math:`S_w, A, N_z, t_c` seem to be the most correlated with the wing weight in absolute value. Pearson and Spearman coefficients do not reveal any linear nor monotonic correlation as no coefficients are equal to +/- 1. Coefficients about :math:`t_c` are negative revealing a negative correlation with the wing weight, that is consistent with the model expression. .. GENERATED FROM PYTHON SOURCE LINES 237-240 Taylor expansion importance factors ----------------------------------- We compute here the Taylor expansion importance factors using :class:`~openturns.TaylorExpansionMoments`. .. GENERATED FROM PYTHON SOURCE LINES 244-245 We create a distribution-based RandomVector. .. GENERATED FROM PYTHON SOURCE LINES 245-247 .. code-block:: Python X = ot.RandomVector(m.distributionX) .. GENERATED FROM PYTHON SOURCE LINES 248-249 We create a composite RandomVector Y from X and m.model. .. GENERATED FROM PYTHON SOURCE LINES 249-251 .. code-block:: Python Y = ot.CompositeRandomVector(m.model, X) .. GENERATED FROM PYTHON SOURCE LINES 252-253 We create a Taylor expansion method to approximate moments. .. GENERATED FROM PYTHON SOURCE LINES 253-255 .. code-block:: Python taylor = ot.TaylorExpansionMoments(Y) .. GENERATED FROM PYTHON SOURCE LINES 256-257 We get the importance factors. .. GENERATED FROM PYTHON SOURCE LINES 257-259 .. code-block:: Python print(taylor.getImportanceFactors()) .. rst-class:: sphx-glr-script-out .. code-block:: none [Sw : 0.130315, Wfw : 2.94004e-06, A : 0.228153, Lambda : 0, q : 8.25053e-05, l : 0.00180269, tc : 0.135002, Nz : 0.412794, Wdg : 0.0883317, Wp : 0.00351621] .. GENERATED FROM PYTHON SOURCE LINES 260-261 We draw the importance factors .. GENERATED FROM PYTHON SOURCE LINES 261-265 .. code-block:: Python graph = taylor.drawImportanceFactors() graph.setTitle("Taylor expansion imporfance factors - Wing weight") view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_009.png :alt: Taylor expansion imporfance factors - Wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_009.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 266-268 The Taylor expansion importance factors is consistent with the previous estimators as :math:`S_w, A, N_z, t_c` seem to be the most influent variables. To analyze the relevance of the previous indices, a Sobol' analysis is now carried out. .. GENERATED FROM PYTHON SOURCE LINES 271-274 Sobol' indices -------------- We compute the Sobol' indices from both sampling approach and Polynomial Chaos Expansion. .. GENERATED FROM PYTHON SOURCE LINES 276-283 .. code-block:: Python sizeSobol = 1000 sie = ot.SobolIndicesExperiment(m.distributionX, sizeSobol) inputDesignSobol = sie.generate() inputNames = m.distributionX.getDescription() inputDesignSobol.setDescription(inputNames) inputDesignSobol.getSize() .. rst-class:: sphx-glr-script-out .. code-block:: none 12000 .. GENERATED FROM PYTHON SOURCE LINES 284-285 We see that 12000 function evaluations are required to estimate the first order and total Sobol' indices. .. GENERATED FROM PYTHON SOURCE LINES 287-288 Then, we evaluate the outputs corresponding to this design of experiments. .. GENERATED FROM PYTHON SOURCE LINES 290-292 .. code-block:: Python outputDesignSobol = m.model(inputDesignSobol) .. GENERATED FROM PYTHON SOURCE LINES 293-294 We estimate the Sobol' indices with the :class:`~openturns.SaltelliSensitivityAlgorithm`. .. GENERATED FROM PYTHON SOURCE LINES 296-300 .. code-block:: Python sensitivityAnalysis = ot.SaltelliSensitivityAlgorithm( inputDesignSobol, outputDesignSobol, sizeSobol ) .. GENERATED FROM PYTHON SOURCE LINES 301-302 The `getFirstOrderIndices` and `getTotalOrderIndices` methods respectively return estimates of all first order and total Sobol' indices. .. GENERATED FROM PYTHON SOURCE LINES 304-306 .. code-block:: Python print("First order indices:", sensitivityAnalysis.getFirstOrderIndices()) .. rst-class:: sphx-glr-script-out .. code-block:: none First order indices: [0.0895403,-0.0324985,0.224239,-0.0324775,-0.0326605,-0.0297425,0.111533,0.459428,0.0692415,-0.0257065]#10 .. GENERATED FROM PYTHON SOURCE LINES 307-310 .. code-block:: Python print("Total order indices:", sensitivityAnalysis.getTotalOrderIndices()) .. rst-class:: sphx-glr-script-out .. code-block:: none Total order indices: [0.132254,1.75663e-05,0.25098,0.000159035,0.000417434,0.000214447,0.144213,0.410061,0.101327,0.00225025]#10 .. GENERATED FROM PYTHON SOURCE LINES 311-312 The `draw` method produces the following graph. The vertical bars represent the 95% confidence intervals of the estimates. .. GENERATED FROM PYTHON SOURCE LINES 314-318 .. code-block:: Python graph = sensitivityAnalysis.draw() graph.setTitle("Sobol indices with Saltelli - wing weight") view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_010.png :alt: Sobol indices with Saltelli - wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_010.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 319-320 We see that several Sobol' indices are negative, that is inconsistent with the theory. Therefore, a larger number of samples is required to get consistent indices .. GENERATED FROM PYTHON SOURCE LINES 320-339 .. code-block:: Python sizeSobol = 10000 sie = ot.SobolIndicesExperiment(m.distributionX, sizeSobol) inputDesignSobol = sie.generate() inputNames = m.distributionX.getDescription() inputDesignSobol.setDescription(inputNames) inputDesignSobol.getSize() outputDesignSobol = m.model(inputDesignSobol) sensitivityAnalysis = ot.SaltelliSensitivityAlgorithm( inputDesignSobol, outputDesignSobol, sizeSobol ) sensitivityAnalysis.getFirstOrderIndices() sensitivityAnalysis.getTotalOrderIndices() graph = sensitivityAnalysis.draw() graph.setTitle("Sobol indices with Saltelli - wing weight") view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_011.png :alt: Sobol indices with Saltelli - wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_011.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 340-341 It improves the accuracy of the estimation but, for very low indices, Saltelli scheme is not accurate since several confidence intervals provide negative lower bounds. .. GENERATED FROM PYTHON SOURCE LINES 343-345 Now, we estimate the Sobol' indices using Polynomial Chaos Expansion. We create a Functional Chaos Expansion. .. GENERATED FROM PYTHON SOURCE LINES 345-356 .. code-block:: Python sizePCE = 800 inputDesignPCE = m.distributionX.getSample(sizePCE) outputDesignPCE = m.model(inputDesignPCE) algo = ot.FunctionalChaosAlgorithm(inputDesignPCE, outputDesignPCE, m.distributionX) algo.run() result = algo.getResult() print(result.getResiduals()) print(result.getRelativeErrors()) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.000354133] [3.92638e-08] .. GENERATED FROM PYTHON SOURCE LINES 357-359 The relative errors are low : this indicates that the PCE model has good accuracy. Then, we exploit the surrogate model to compute the Sobol' indices. .. GENERATED FROM PYTHON SOURCE LINES 359-367 .. code-block:: Python sensitivityAnalysis = ot.FunctionalChaosSobolIndices(result) print(sensitivityAnalysis) firstOrder = [sensitivityAnalysis.getSobolIndex(i) for i in range(m.dim)] totalOrder = [sensitivityAnalysis.getSobolTotalIndex(i) for i in range(m.dim)] graph = ot.SobolIndicesAlgorithm.DrawSobolIndices(inputNames, firstOrder, totalOrder) graph.setTitle("Sobol indices by Polynomial Chaos Expansion - wing weight") view = otv.View(graph) .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_012.png :alt: Sobol indices by Polynomial Chaos Expansion - wing weight :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_012.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none FunctionalChaosSobolIndices - input dimension=10 - output dimension=1 - basis size=761 - mean=[268.091] - std-dev=[48.0753] | Index | Multi-index | Variance part | |-------|---------------|---------------| | 8 | [0,0,0,0,0,0,0,1,0,0]| 0.410346 | | 3 | [0,0,1,0,0,0,0,0,0,0]| 0.220101 | | 7 | [0,0,0,0,0,0,1,0,0,0]| 0.138523 | | 1 | [1,0,0,0,0,0,0,0,0,0]| 0.124359 | | 9 | [0,0,0,0,0,0,0,0,1,0]| 0.084929 | | Input | Name | Sobol' index | Total index | |-------|---------------|---------------|---------------| | 0 | Sw | 0.124369 | 0.12777 | | 1 | Wfw | 2.86879e-06 | 8.73386e-06 | | 2 | A | 0.220239 | 0.225947 | | 3 | Lambda | 0.000476574 | 0.000497729 | | 4 | q | 9.03999e-05 | 9.95421e-05 | | 5 | l | 0.00180163 | 0.00186647 | | 6 | tc | 0.141095 | 0.145208 | | 7 | Nz | 0.411656 | 0.41965 | | 8 | Wdg | 0.0849832 | 0.0876488 | | 9 | Wp | 0.00331824 | 0.00334452 | .. GENERATED FROM PYTHON SOURCE LINES 368-374 The Sobol' indices confirm the previous analyses, in terms of ranking of the most influent variables. We also see that five variables have a quasi null total Sobol' indices, that indicates almost no influence on the wing weight. There is no discrepancy between first order and total Sobol' indices, that indicates no or very low interaction between the variables in the variance of the output. As the most important variables act only through decoupled first degree contributions, the hypothesis of a linear dependence between the input variables and the weight is legitimate. This explains why both squared SRC and Taylor give the exact same results even if the first one is based on a :math:`\mathcal{L}^2` linear approximation and the second one is based on a linear expansion around the mean value of the input variables. .. GENERATED FROM PYTHON SOURCE LINES 378-380 HSIC indices ------------ .. GENERATED FROM PYTHON SOURCE LINES 382-383 We then estimate the HSIC indices using a data-driven approach. .. GENERATED FROM PYTHON SOURCE LINES 383-389 .. code-block:: Python sizeHSIC = 250 inputDesignHSIC = m.distributionX.getSample(sizeHSIC) outputDesignHSIC = m.model(inputDesignHSIC) covarianceModelCollection = [] .. GENERATED FROM PYTHON SOURCE LINES 390-396 .. code-block:: Python for i in range(m.dim): Xi = inputDesignHSIC.getMarginal(i) inputCovariance = ot.SquaredExponential(1) inputCovariance.setScale(Xi.computeStandardDeviation()) covarianceModelCollection.append(inputCovariance) .. GENERATED FROM PYTHON SOURCE LINES 397-398 We define a covariance kernel associated to the output variable. .. GENERATED FROM PYTHON SOURCE LINES 398-402 .. code-block:: Python outputCovariance = ot.SquaredExponential(1) outputCovariance.setScale(outputDesignHSIC.computeStandardDeviation()) covarianceModelCollection.append(outputCovariance) .. GENERATED FROM PYTHON SOURCE LINES 403-405 In this paragraph, we perform the analysis on the raw data: that is the global HSIC estimator. .. GENERATED FROM PYTHON SOURCE LINES 405-407 .. code-block:: Python estimatorType = ot.HSICUStat() .. GENERATED FROM PYTHON SOURCE LINES 408-409 We now build the HSIC estimator: .. GENERATED FROM PYTHON SOURCE LINES 409-413 .. code-block:: Python globHSIC = ot.HSICEstimatorGlobalSensitivity( covarianceModelCollection, inputDesignHSIC, outputDesignHSIC, estimatorType ) .. GENERATED FROM PYTHON SOURCE LINES 414-415 We get the R2-HSIC indices: .. GENERATED FROM PYTHON SOURCE LINES 415-419 .. code-block:: Python R2HSICIndices = globHSIC.getR2HSICIndices() print("\n Global HSIC analysis") print("R2-HSIC Indices: ", R2HSICIndices) .. rst-class:: sphx-glr-script-out .. code-block:: none Global HSIC analysis R2-HSIC Indices: [0.102709,-0.00336782,0.148905,0.000299579,-0.00488949,0.00479322,0.0845911,0.34874,0.0601762,-0.00321501]#10 .. GENERATED FROM PYTHON SOURCE LINES 420-421 and the HSIC indices: .. GENERATED FROM PYTHON SOURCE LINES 421-424 .. code-block:: Python HSICIndices = globHSIC.getHSICIndices() print("HSIC Indices: ", HSICIndices) .. rst-class:: sphx-glr-script-out .. code-block:: none HSIC Indices: [0.00906902,-0.000293314,0.013635,2.72569e-05,-0.000444497,0.000436191,0.00777676,0.0309526,0.00545591,-0.000300297]#10 .. GENERATED FROM PYTHON SOURCE LINES 425-426 The p-value by permutation. .. GENERATED FROM PYTHON SOURCE LINES 426-429 .. code-block:: Python pvperm = globHSIC.getPValuesPermutation() print("p-value (permutation): ", pvperm) .. rst-class:: sphx-glr-script-out .. code-block:: none p-value (permutation): [0,0.712871,0,0.376238,0.841584,0.128713,0,0,0,0.712871]#10 .. GENERATED FROM PYTHON SOURCE LINES 430-431 We have an asymptotic estimate of the value for this estimator. .. GENERATED FROM PYTHON SOURCE LINES 431-434 .. code-block:: Python pvas = globHSIC.getPValuesAsymptotic() print("p-value (asymptotic): ", pvas) .. rst-class:: sphx-glr-script-out .. code-block:: none p-value (asymptotic): [3.02901e-12,0.680845,1.28369e-16,0.392815,0.82049,0.169798,1.63072e-09,6.32092e-35,4.2536e-07,0.675604]#10 .. GENERATED FROM PYTHON SOURCE LINES 435-436 We vizualise the results. .. GENERATED FROM PYTHON SOURCE LINES 436-448 .. code-block:: Python graph1 = globHSIC.drawHSICIndices() view1 = otv.View(graph1) graph2 = globHSIC.drawPValuesAsymptotic() view2 = otv.View(graph2) graph3 = globHSIC.drawR2HSICIndices() view3 = otv.View(graph3) graph4 = globHSIC.drawPValuesPermutation() view4 = otv.View(graph4) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_013.png :alt: HSIC indices :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_013.png :class: sphx-glr-multi-img * .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_014.png :alt: Asymptotic p-values :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_014.png :class: sphx-glr-multi-img * .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_015.png :alt: R2-HSIC indices :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_015.png :class: sphx-glr-multi-img * .. image-sg:: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_016.png :alt: p-values by permutation :srcset: /auto_reliability_sensitivity/sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_016.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 449-452 The HSIC indices go in the same way as the other estimators in terms the most influent variables. The variables :math:`W_{fw}, q, l, W_p` seem to be independent to the output as the corresponding p-values are high. We can also see that the asymptotic p-values and p-values estimated by permutation are quite similar. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 5.609 seconds) .. _sphx_glr_download_auto_reliability_sensitivity_sensitivity_analysis_plot_sensitivity_wingweight.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_wingweight.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sensitivity_wingweight.py `