Comparing sensitivity indices

from __future__ import annotations

from gemseo.uncertainty.sensitivity.correlation.analysis import CorrelationAnalysis
from gemseo.uncertainty.sensitivity.morris.analysis import MorrisAnalysis
from gemseo.uncertainty.use_cases.ishigami.ishigami_discipline import IshigamiDiscipline
from gemseo.uncertainty.use_cases.ishigami.ishigami_space import IshigamiSpace

In this example, we consider the Ishigami function [IH90]

\[f(x_1,x_2,x_3)=\sin(x_1)+7\sin(x_2)^2+0.1*x_3^4\sin(x_1)\]

implemented as an MDODiscipline by the IshigamiDiscipline. It is commonly used with the independent random variables \(X_1\), \(X_2\) and \(X_3\) uniformly distributed between \(-\pi\) and \(\pi\) and defined in the IshigamiSpace.

discipline = IshigamiDiscipline()
uncertain_space = IshigamiSpace()

We would like to carry out two sensitivity analyses, e.g. a first one based on correlation coefficients and a second one based on the Morris methodology, and compare the results,

Firstly, we create a CorrelationAnalysis and compute the sensitivity indices:

correlation = CorrelationAnalysis([discipline], uncertain_space, 10)
correlation.compute_indices()
{'pearson': {'y': [{'x1': array([0.685388]), 'x2': array([0.09681897]), 'x3': array([-0.23027298])}]}, 'spearman': {'y': [{'x1': array([0.74545455]), 'x2': array([0.04242424]), 'x3': array([-0.09090909])}]}, 'pcc': {'y': [{'x1': array([0.84696461]), 'x2': array([0.68814608]), 'x3': array([-0.29846394])}]}, 'prcc': {'y': [{'x1': array([0.90374102]), 'x2': array([0.76539572]), 'x3': array([-0.02232206])}]}, 'src': {'y': [{'x1': array([0.94001308]), 'x2': array([0.55748872]), 'x3': array([-0.16157012])}]}, 'srrc': {'y': [{'x1': array([1.06252802]), 'x2': array([0.60167726]), 'x3': array([-0.00959941])}]}, 'ssrrc': {'y': [{'x1': array([0.94001308]), 'x2': array([0.55748872]), 'x3': array([-0.16157012])}]}}

Then, we create a MorrisAnalysis and compute the sensitivity indices:

morris = MorrisAnalysis([discipline], uncertain_space, 10)
morris.compute_indices()
{'mu': {'y': [{'x1': array([-0.36000398]), 'x2': array([0.77781853]), 'x3': array([-0.70990541])}]}, 'mu_star': {'y': [{'x1': array([0.67947346]), 'x2': array([0.88906579]), 'x3': array([0.72694219])}]}, 'sigma': {'y': [{'x1': array([0.98724949]), 'x2': array([0.79064599]), 'x3': array([0.8074493])}]}, 'relative_sigma': {'y': [{'x1': array([1.45296254]), 'x2': array([0.88929976]), 'x3': array([1.11074761])}]}, 'min': {'y': [{'x1': array([0.0338188]), 'x2': array([0.11821721]), 'x3': array([8.72820113e-05])}]}, 'max': {'y': [{'x1': array([2.2360336]), 'x2': array([1.83987522]), 'x3': array([2.12052546])}]}}

Lastly, we compare these analyses with the graphical method SensitivityAnalysis.plot_comparison(), either using a bar chart:

morris.plot_comparison(correlation, "y", use_bar_plot=True, save=False, show=True)
plot sensitivity comparison
<gemseo.post.dataset.bars.BarPlot object at 0x7f3d28db28e0>

or a radar plot:

morris.plot_comparison(correlation, "y", use_bar_plot=False, save=False, show=True)
plot sensitivity comparison
<gemseo.post.dataset.radar_chart.RadarChart object at 0x7f3d28cf75b0>

Total running time of the script: ( 0 minutes 0.514 seconds)

Gallery generated by Sphinx-Gallery