Examples¶
This section illustrates how to use the module to evaluate the Morris screening effects.
The illustration is done with the Morris function example, ie f: . Each input variable is uniform with bounds 0 and 1.
Example 1: Morris use-case and p-level input grid¶
To define the trajectories, we suppose that the box is splitted into a p-level grid (p=5).
We set the number of trajectories input variables are randomly to 10.
import openturns as ot
from openturns.viewer import View
import otmorris
# use the reference 20-d function from the Morris paper
f = ot.Function(otmorris.MorrisFunction())
dim = f.getInputDimension()
# Number of trajectories
r = 10
# Define experiments in [0,1]^20
# p-levels
p = 5
morris_experiment = otmorris.MorrisExperimentGrid([p] * dim, r)
bounds = ot.Interval(dim) # [0,1]^d
X = morris_experiment.generate()
Y = f(X)
# Evaluate Elementary effects (ee)
morris = otmorris.Morris(X, Y, bounds)
# Compute mu/sigma
mean = morris.getMeanAbsoluteElementaryEffects()
sigma = morris.getStandardDeviationElementaryEffects()
graph = morris.drawElementaryEffects(0)
View(graph).show()
We illustrate here after sensitivity graph issued from such analysis:
Example 2: Morris use-case and LHS initial design¶
To define the trajectories, we first get an LHS design in the box of
We set the number of trajectories input variables are randomly to 10.
import openturns as ot
import otmorris
from openturns.viewer import View
# use the reference 20-d function from the Morris paper
f = ot.Function(otmorris.MorrisFunction())
dim = f.getInputDimension()
# Number of trajectories
r = 10
# Define an LHS experiment of size 50 in [0, 1]^20
size = 50
dist = ot.ComposedDistribution([ot.Uniform(0, 1)] * dim)
lhs_experiment = ot.LHSExperiment(dist, size, True, False)
lhsDesign = lhs_experiment.generate()
morris_experiment = otmorris.MorrisExperimentLHS(lhsDesign, r)
bounds = ot.Interval(dim) # [0, 1]^20
X = morris_experiment.generate()
Y = f(X)
# Evaluate Elementary effects (ee)
morris = otmorris.Morris(X, Y, bounds)
# Compute mu/sigma
mean = morris.getMeanAbsoluteElementaryEffects()
sigma = morris.getStandardDeviationElementaryEffects()
graph = morris.drawElementaryEffects(0)
graph.setTitle("Elementary Effects using LHS")
View(graph).show()
We illustrate here after sensitivity graph issued from such analysis: