Morris analysis

from __future__ import annotations

import pprint

from gemseo import configure_logger
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

<RootLogger root (INFO)>

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


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()

Then, we run sensitivity analysis of type MorrisAnalysis:

sensitivity_analysis = MorrisAnalysis([discipline], uncertain_space, n_samples=None)
 WARNING - 13:53:44: No coupling in MDA, switching chain_linearize to True.
 WARNING - 13:53:44: No coupling in MDA, switching chain_linearize to True.
    INFO - 13:53:44:
    INFO - 13:53:44: *** Start MorrisAnalysisSamplingPhase execution ***
    INFO - 13:53:44: MorrisAnalysisSamplingPhase
    INFO - 13:53:44:    Disciplines: _OATSensitivity
    INFO - 13:53:44:    MDO formulation: MDF
    INFO - 13:53:44: Running the algorithm lhs:
    INFO - 13:53:44:     20%|██        | 1/5 [00:00<00:00, 50.66 it/sec]
    INFO - 13:53:44:     40%|████      | 2/5 [00:00<00:00, 82.56 it/sec]
    INFO - 13:53:44:     60%|██████    | 3/5 [00:00<00:00, 105.17 it/sec]
    INFO - 13:53:44:     80%|████████  | 4/5 [00:00<00:00, 121.64 it/sec]
    INFO - 13:53:44:    100%|██████████| 5/5 [00:00<00:00, 134.43 it/sec]
    INFO - 13:53:44: *** End MorrisAnalysisSamplingPhase execution (time: 0:00:00.050710) ***

{'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])}]}}

The resulting indices are the empirical means and the standard deviations of the absolute output variations due to input changes.

{'MAX': {'y': [{'x1': array([2.2360336]),
                'x2': array([1.83987522]),
                'x3': array([2.12052546])}]},
 'MIN': {'y': [{'x1': array([0.0338188]),
                'x2': array([0.11821721]),
                'x3': array([8.72820113e-05])}]},
 '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])}]},
 'RELATIVE_SIGMA': {'y': [{'x1': array([1.45296254]),
                           'x2': array([0.88929976]),
                           'x3': array([1.11074761])}]},
 'SIGMA': {'y': [{'x1': array([0.98724949]),
                  'x2': array([0.79064599]),
                  'x3': array([0.8074493])}]}}

The main indices corresponds to these empirical means (this main method can be changed with MorrisAnalysis.main_method):

{'y': [{'x1': array([0.67947346]),
        'x2': array([0.88906579]),
        'x3': array([0.72694219])}]}

and can be interpreted with respect to the empirical bounds of the outputs:

{'y': [array([-1.00881748]), array([14.89344259])]}

We can also get the input parameters sorted by decreasing order of influence:

['x2', 'x3', 'x1']

We can use the method MorrisAnalysis.plot() to visualize the different series of indices:

sensitivity_analysis.plot("y", save=False, show=True, lower_mu=0, lower_sigma=0)
Sampling: lhs(size=5) - Relative step: 0.05 - Output: y
<Figure size 640x480 with 1 Axes>

Lastly, the sensitivity indices can be exported to a Dataset:

VARIABLE y y y y y y
COMPONENT 0 0 0 0 0 0
x1 -0.360004 0.679473 0.987249 1.452963 0.033819 2.236034
x2 0.777819 0.889066 0.790646 0.889300 0.118217 1.839875
x3 -0.709905 0.726942 0.807449 1.110748 0.000087 2.120525

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

Gallery generated by Sphinx-Gallery