File: plot_sensitivity_fast.py

package info (click to toggle)
openturns 1.24-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,204 kB
  • sloc: cpp: 256,662; python: 63,381; ansic: 4,414; javascript: 406; sh: 180; xml: 164; yacc: 123; makefile: 98; lex: 55
file content (74 lines) | stat: -rw-r--r-- 2,329 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
FAST sensitivity indices
========================
"""

# %%
# This example will demonstrate how to quantify the correlation between the input
# variables and the output variable of a model using the FAST method,
# based upon the Fourier decomposition of the model response,
# which is a relevant alternative to the classical
# simulation approach for computing Sobol sensitivity indices.
#
# The FAST indices, like the Sobol indices, allow one to
# evaluate the importance of a single variable or a specific set of variables.
#
# In theory, FAST indices range is :math:`\left[0; 1\right]` ; the closer to 1 the
# index is, the greater the model response sensitivity to the variable is.
#
# The FAST method compute the first and total order indices.
# The first order indices evaluate the importance of one variable at a time
# (:math:`d` indices, with :math:`d` the input dimension of the model).
#
# The :math:`d` total indices give the relative importance of every variables except
# the variable :math:`X_i`, for every variable.

# %%
from openturns.usecases import ishigami_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt

ot.Log.Show(ot.Log.NONE)

# %%
# We load the :ref:`Ishigami model <use-case-ishigami>` from the usecases module :
im = ishigami_function.IshigamiModel()

# %%
# The `IshigamiModel` data class contains the input independent joint distribution :
distribution = im.inputDistribution

# %%
# and the Ishigami function :
model = im.model


# %%
size = 400
sensitivityAnalysis = ot.FAST(model, distribution, size)
# Compute the first order indices (first and total order indices are
# computed together)
firstOrderIndices = sensitivityAnalysis.getFirstOrderIndices()
# Retrieve total order indices
totalOrderIndices = sensitivityAnalysis.getTotalOrderIndices()

# %%
# Print indices
print("First order FAST indices:", firstOrderIndices)
print("Total order FAST indices:", totalOrderIndices)

# %%
graph = ot.SobolIndicesAlgorithm.DrawImportanceFactors(
    firstOrderIndices, distribution.getDescription(), "FAST first order indices"
)
view = viewer.View(graph)

# %%
graph = ot.SobolIndicesAlgorithm.DrawImportanceFactors(
    totalOrderIndices, distribution.getDescription(), "FAST total order indices"
)
view = viewer.View(graph)
plt.show()

# %%