.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_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_sensitivity_analysis_plot_sensitivity_wingweight.py: Example of sensitivity analyses on the wing weight model ========================================================= .. GENERATED FROM PYTHON SOURCE LINES 7-21 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 - Rank-based estimation of 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 24-30 Definition of the model ----------------------- We load the model from the usecases module. .. GENERATED FROM PYTHON SOURCE LINES 30-36 .. code-block:: Python import openturns as ot import openturns.viewer as otv from openturns.usecases.wingweight_function import WingWeightModel m = WingWeightModel() .. GENERATED FROM PYTHON SOURCE LINES 37-44 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. .. GENERATED FROM PYTHON SOURCE LINES 44-85 .. code-block:: Python lowerBound = m.distribution.getRange().getLowerBound() upperBound = m.distribution.getRange().getUpperBound() nX = ot.ResourceMap.GetAsUnsignedInteger("Evaluation-DefaultPointNumber") description = m.distribution.getDescription() description.add("") m.model.setDescription(description) m.model.setName("wing weight model") grid = m.model.drawCrossCuts( m.distribution.getMean(), lowerBound, upperBound, [nX] * m.model.getInputDimension(), False, True, 176.0, 363.0, ) grid.setTitle("") # Get View object to manipulate the underlying figure # Here we decide the colormap and the number of levels used for all contours view = otv.View(grid, contour_kw={"cmap": "hsv", "levels": 55}) axes = view.getAxes() fig = view.getFigure() fig.set_size_inches(12, 12) # reduce the size # Setup a large colorbar fig.colorbar( view.getSubviews()[1][0].getContourSets()[0], ax=axes[:-2, -1], fraction=0.3 ) # Hide unwanted axes labels for i in range(len(axes)): for j in range(i + 1): if i < len(axes) - 1: axes[i][j].xaxis.set_ticklabels([]) if j > 0: axes[i][j].yaxis.set_ticklabels([]) fig.subplots_adjust(top=0.99, bottom=0.05, left=0.06, right=0.99) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_001.svg :alt: plot sensitivity wingweight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_001.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 86-87 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 89-93 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 93-100 .. code-block:: Python inputNames = m.distribution.getDescription() size = 500 inputDesign = m.distribution.getSample(size) outputDesign = m.model(inputDesign) .. GENERATED FROM PYTHON SOURCE LINES 101-103 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 103-106 .. code-block:: Python corr_analysis = ot.CorrelationAnalysis(inputDesign, outputDesign) .. GENERATED FROM PYTHON SOURCE LINES 107-110 PCC coefficients ---------------- We compute here PCC coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 112-115 .. code-block:: Python pcc_indices = corr_analysis.computePCC() print(pcc_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.935621,0.0162693,0.960722,0.0190557,0.104993,0.316626,-0.937934,0.977742,0.901198,0.393856]#10 .. GENERATED FROM PYTHON SOURCE LINES 119-124 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( pcc_indices, inputNames, "PCC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_002.svg :alt: PCC coefficients - Wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_002.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 125-128 PRCC coefficients ----------------- We compute here PRCC coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 130-133 .. code-block:: Python prcc_indices = corr_analysis.computePRCC() print(prcc_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.835669,0.0179569,0.891497,-0.0245634,0.0465254,0.149125,-0.836508,0.939886,0.756455,0.240063]#10 .. GENERATED FROM PYTHON SOURCE LINES 134-139 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( prcc_indices, inputNames, "PRCC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_003.svg :alt: PRCC coefficients - Wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_003.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 140-143 SRC coefficients ------------------- We compute here SRC coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 145-148 .. code-block:: Python src_indices = corr_analysis.computeSRC() print(src_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.356019,0.00219694,0.465469,0.00257789,0.0141461,0.0452397,-0.364839,0.630624,0.278983,0.0574538]#10 .. GENERATED FROM PYTHON SOURCE LINES 149-154 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( src_indices, inputNames, "SRC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_004.svg :alt: SRC coefficients - Wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_004.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 155-156 Normalized squared SRC coefficients (coefficients are made to sum to 1) : .. GENERATED FROM PYTHON SOURCE LINES 158-161 .. code-block:: Python squared_src_indices = corr_analysis.computeSquaredSRC(True) print(squared_src_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.132363,5.04029e-06,0.226255,6.9398e-06,0.000208972,0.00213726,0.139002,0.415297,0.0812779,0.00344711]#10 .. GENERATED FROM PYTHON SOURCE LINES 162-163 And their associated graph: .. GENERATED FROM PYTHON SOURCE LINES 165-170 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( squared_src_indices, inputNames, "Squared SRC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_005.svg :alt: Squared SRC coefficients - Wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_005.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 174-177 SRRC coefficients -------------------- We compute here SRRC coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 179-182 .. code-block:: Python srrc_indices = corr_analysis.computeSRRC() print(srrc_indices) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.348313,0.0041313,0.450607,-0.00566494,0.0106347,0.0348243,-0.350926,0.634484,0.264415,0.0564672]#10 .. GENERATED FROM PYTHON SOURCE LINES 183-188 .. code-block:: Python graph = ot.SobolIndicesAlgorithm.DrawCorrelationCoefficients( srrc_indices, inputNames, "SRRC coefficients - Wing weight" ) view = otv.View(graph) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_006.svg :alt: SRRC coefficients - Wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_006.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 189-192 Pearson coefficients ----------------------- We compute here the Pearson :math:`\rho` coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 194-197 .. code-block:: Python pearson_correlation = corr_analysis.computeLinearCorrelation() print(pearson_correlation) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.406027,-0.0618226,0.434929,-0.0140118,0.019329,0.162599,-0.417202,0.618386,0.279206,0.133176]#10 .. GENERATED FROM PYTHON SOURCE LINES 198-204 .. 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_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_007.svg :alt: Pearson correlation coefficients - Wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_007.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 205-208 Spearman coefficients ----------------------- We compute here the Spearman :math:`\rho_s` coefficients using the :class:`~openturns.CorrelationAnalysis`. .. GENERATED FROM PYTHON SOURCE LINES 210-213 .. code-block:: Python spearman_correlation = corr_analysis.computeSpearmanCorrelation() print(spearman_correlation) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.399219,-0.0583024,0.422034,-0.0218708,0.0167429,0.150902,-0.405743,0.621177,0.265084,0.126477]#10 .. GENERATED FROM PYTHON SOURCE LINES 214-220 .. 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) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_008.svg :alt: Spearman correlation coefficients - Wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_008.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 221-224 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 228-231 Taylor expansion importance factors ----------------------------------- We compute here the Taylor expansion importance factors using :class:`~openturns.TaylorExpansionMoments`. .. GENERATED FROM PYTHON SOURCE LINES 235-236 We create a distribution-based RandomVector. .. GENERATED FROM PYTHON SOURCE LINES 236-238 .. code-block:: Python X = ot.RandomVector(m.distribution) .. GENERATED FROM PYTHON SOURCE LINES 239-240 We create a composite RandomVector Y from X and m.model. .. GENERATED FROM PYTHON SOURCE LINES 240-242 .. code-block:: Python Y = ot.CompositeRandomVector(m.model, X) .. GENERATED FROM PYTHON SOURCE LINES 243-244 We create a Taylor expansion method to approximate moments. .. GENERATED FROM PYTHON SOURCE LINES 244-246 .. code-block:: Python taylor = ot.TaylorExpansionMoments(Y) .. GENERATED FROM PYTHON SOURCE LINES 247-248 We get the importance factors. .. GENERATED FROM PYTHON SOURCE LINES 248-250 .. 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 251-252 We draw the importance factors .. GENERATED FROM PYTHON SOURCE LINES 252-256 .. code-block:: Python graph = taylor.drawImportanceFactors() graph.setTitle("Taylor expansion imporfance factors - Wing weight") view = otv.View(graph) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_009.svg :alt: Taylor expansion imporfance factors - Wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_009.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 257-259 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 262-265 Sobol' indices -------------- We compute the Sobol' indices from both sampling approach and Polynomial Chaos Expansion. .. GENERATED FROM PYTHON SOURCE LINES 267-274 .. code-block:: Python sizeSobol = 1000 sie = ot.SobolIndicesExperiment(m.distribution, sizeSobol) inputDesignSobol = sie.generate() inputNames = m.distribution.getDescription() inputDesignSobol.setDescription(inputNames) inputDesignSobol.getSize() .. rst-class:: sphx-glr-script-out .. code-block:: none 12000 .. GENERATED FROM PYTHON SOURCE LINES 275-276 We see that 12000 function evaluations are required to estimate the first order and total Sobol' indices. .. GENERATED FROM PYTHON SOURCE LINES 278-279 Then, we evaluate the outputs corresponding to this design of experiments. .. GENERATED FROM PYTHON SOURCE LINES 281-283 .. code-block:: Python outputDesignSobol = m.model(inputDesignSobol) .. GENERATED FROM PYTHON SOURCE LINES 284-285 We estimate the Sobol' indices with the :class:`~openturns.SaltelliSensitivityAlgorithm`. .. GENERATED FROM PYTHON SOURCE LINES 287-291 .. code-block:: Python sensitivityAnalysis = ot.SaltelliSensitivityAlgorithm( inputDesignSobol, outputDesignSobol, sizeSobol ) .. GENERATED FROM PYTHON SOURCE LINES 292-293 The `getFirstOrderIndices` and `getTotalOrderIndices` methods respectively return estimates of all first order and total Sobol' indices. .. GENERATED FROM PYTHON SOURCE LINES 295-297 .. code-block:: Python print("First order indices:", sensitivityAnalysis.getFirstOrderIndices()) .. rst-class:: sphx-glr-script-out .. code-block:: none First order indices: [0.156759,0.0290035,0.214508,0.0286627,0.0284787,0.0317074,0.183241,0.435572,0.105108,0.0332948]#10 .. GENERATED FROM PYTHON SOURCE LINES 298-301 .. code-block:: Python print("Total order indices:", sensitivityAnalysis.getTotalOrderIndices()) .. rst-class:: sphx-glr-script-out .. code-block:: none Total order indices: [0.101709,-2.77254e-05,0.209056,0.00230855,0.00088888,-0.000335256,0.155822,0.41227,0.100738,0.000190837]#10 .. GENERATED FROM PYTHON SOURCE LINES 302-303 The `draw` method produces the following graph. The vertical bars represent the 95% confidence intervals of the estimates. .. GENERATED FROM PYTHON SOURCE LINES 305-309 .. code-block:: Python graph = sensitivityAnalysis.draw() graph.setTitle("Sobol indices with Saltelli - wing weight") view = otv.View(graph) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_010.svg :alt: Sobol indices with Saltelli - wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_010.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 310-311 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 311-330 .. code-block:: Python sizeSobol = 10000 sie = ot.SobolIndicesExperiment(m.distribution, sizeSobol) inputDesignSobol = sie.generate() inputNames = m.distribution.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_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_011.svg :alt: Sobol indices with Saltelli - wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_011.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 331-332 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 334-336 Now, we estimate the Sobol' indices using Polynomial Chaos Expansion. We create a Functional Chaos Expansion. .. GENERATED FROM PYTHON SOURCE LINES 336-345 .. code-block:: Python sizePCE = 800 inputDesignPCE = m.distribution.getSample(sizePCE) outputDesignPCE = m.model(inputDesignPCE) algo = ot.FunctionalChaosAlgorithm(inputDesignPCE, outputDesignPCE, m.distribution) algo.run() result = algo.getResult() .. GENERATED FROM PYTHON SOURCE LINES 346-347 Then, we exploit the surrogate model to compute the Sobol' indices. .. GENERATED FROM PYTHON SOURCE LINES 347-350 .. code-block:: Python sensitivityAnalysis = ot.FunctionalChaosSobolIndices(result) sensitivityAnalysis .. raw:: html
FunctionalChaosSobolIndices
  • input dimension: 10
  • output dimension: 1
  • basis size: 761
  • mean: [268.076]
  • std-dev: [48.0926]
Input Variable Sobol' index Total index
0 Sw 0.124610 0.128020
1 Wfw 0.000002 0.000006
2 A 0.220301 0.226096
3 Lambda 0.000496 0.000515
4 q 0.000082 0.000089
5 l 0.001810 0.001873
6 tc 0.140783 0.144862
7 Nz 0.411639 0.419673
8 Wdg 0.084892 0.087560
9 Wp 0.003368 0.003393
Index Multi-index Part of variance
8 [0,0,0,0,0,0,0,1,0,0]#10 0.410306
3 [0,0,1,0,0,0,0,0,0,0]#10 0.220156
7 [0,0,0,0,0,0,1,0,0,0]#10 0.138197
1 [1,0,0,0,0,0,0,0,0,0]#10 0.124601
9 [0,0,0,0,0,0,0,0,1,0]#10 0.084838


.. GENERATED FROM PYTHON SOURCE LINES 351-358 .. code-block:: Python 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_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_012.svg :alt: Sobol indices by Polynomial Chaos Expansion - wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_012.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 359-361 Furthermore, first order Sobol' indices can also been estimated in a data-driven way using a rank-based sensitivity algorithm. In such a way, the estimation of sensitivity indices does not involve any surrogate model. .. GENERATED FROM PYTHON SOURCE LINES 361-373 .. code-block:: Python sizeRankSobol = 800 inputDesignRankSobol = m.distribution.getSample(sizeRankSobol) outputDesignankSobol = m.model(inputDesignRankSobol) myRankSobol = ot.RankSobolSensitivityAlgorithm( inputDesignRankSobol, outputDesignankSobol ) indicesrankSobol = myRankSobol.getFirstOrderIndices() print("First order indices:", indicesrankSobol) graph = myRankSobol.draw() graph.setTitle("Sobol indices by rank-based estimation - wing weight") view = otv.View(graph) .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_013.svg :alt: Sobol indices by rank-based estimation - wing weight :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_013.svg :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none First order indices: [0.110075,-0.0332963,0.273983,0.0474846,-0.0277481,-0.0349598,0.13214,0.400101,0.126718,-0.0497129]#10 .. GENERATED FROM PYTHON SOURCE LINES 374-380 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 384-386 HSIC indices ------------ .. GENERATED FROM PYTHON SOURCE LINES 388-389 We then estimate the HSIC indices using a data-driven approach. .. GENERATED FROM PYTHON SOURCE LINES 389-395 .. code-block:: Python sizeHSIC = 250 inputDesignHSIC = m.distribution.getSample(sizeHSIC) outputDesignHSIC = m.model(inputDesignHSIC) covarianceModelCollection = [] .. GENERATED FROM PYTHON SOURCE LINES 396-402 .. 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 403-404 We define a covariance kernel associated to the output variable. .. GENERATED FROM PYTHON SOURCE LINES 404-408 .. code-block:: Python outputCovariance = ot.SquaredExponential(1) outputCovariance.setScale(outputDesignHSIC.computeStandardDeviation()) covarianceModelCollection.append(outputCovariance) .. GENERATED FROM PYTHON SOURCE LINES 409-411 In this paragraph, we perform the analysis on the raw data: that is the global HSIC estimator. .. GENERATED FROM PYTHON SOURCE LINES 411-413 .. code-block:: Python estimatorType = ot.HSICUStat() .. GENERATED FROM PYTHON SOURCE LINES 414-415 We now build the HSIC estimator: .. GENERATED FROM PYTHON SOURCE LINES 415-419 .. code-block:: Python globHSIC = ot.HSICEstimatorGlobalSensitivity( covarianceModelCollection, inputDesignHSIC, outputDesignHSIC, estimatorType ) .. GENERATED FROM PYTHON SOURCE LINES 420-421 We get the R2-HSIC indices: .. GENERATED FROM PYTHON SOURCE LINES 421-425 .. 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.159251,-0.000378845,0.208172,-0.00618487,-0.000766091,0.00490199,0.105402,0.312238,0.0807705,0.0253583]#10 .. GENERATED FROM PYTHON SOURCE LINES 426-427 and the HSIC indices: .. GENERATED FROM PYTHON SOURCE LINES 427-430 .. code-block:: Python HSICIndices = globHSIC.getHSICIndices() print("HSIC Indices: ", HSICIndices) .. rst-class:: sphx-glr-script-out .. code-block:: none HSIC Indices: [0.0132701,-3.22614e-05,0.0180983,-0.000512499,-6.31575e-05,0.00043174,0.00913392,0.0265314,0.00707718,0.00210602]#10 .. GENERATED FROM PYTHON SOURCE LINES 431-432 The p-value by permutation. .. GENERATED FROM PYTHON SOURCE LINES 432-435 .. 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.405941,0,0.940594,0.485149,0.118812,0,0,0,0]#10 .. GENERATED FROM PYTHON SOURCE LINES 436-437 We have an asymptotic estimate of the value for this estimator. .. GENERATED FROM PYTHON SOURCE LINES 437-440 .. code-block:: Python pvas = globHSIC.getPValuesAsymptotic() print("p-value (asymptotic): ", pvas) .. rst-class:: sphx-glr-script-out .. code-block:: none p-value (asymptotic): [7.51146e-16,0.443168,7.04234e-22,0.916533,0.473858,0.167259,1.41574e-11,6.51232e-31,1.84557e-09,0.00176887]#10 .. GENERATED FROM PYTHON SOURCE LINES 441-442 We vizualise the results. .. GENERATED FROM PYTHON SOURCE LINES 442-454 .. 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_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_014.svg :alt: HSIC indices :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_014.svg :class: sphx-glr-multi-img * .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_015.svg :alt: Asymptotic p-values :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_015.svg :class: sphx-glr-multi-img * .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_016.svg :alt: R2-HSIC indices :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_016.svg :class: sphx-glr-multi-img * .. image-sg:: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_017.svg :alt: p-values by permutation :srcset: /auto_sensitivity_analysis/images/sphx_glr_plot_sensitivity_wingweight_017.svg :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 455-458 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. .. GENERATED FROM PYTHON SOURCE LINES 460-461 .. code-block:: Python otv.View.ShowAll() .. _sphx_glr_download_auto_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 ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_sensitivity_wingweight.zip `