In [1]:
import openturns as ot
import numpy as np
import pygosa
%pylab inline
We define Sobol
use-case, which is very common in case of sensitivity analysis:
In [2]:
model = ot.SymbolicFunction(["x1","x2","x3"], ["sin(x1) + 7*sin(x2)^2 + 0.1*(x3^4)*sin(x1)"])
dist = ot.ComposedDistribution( 3 * [ot.Uniform(-np.pi, np.pi)] )
In [3]:
mcsp = pygosa.SensitivityDesign(dist=dist, model=model, size=1000)
The benefits of using a crude
Monte-Carlo approach is the potential use of several contrasts.
In this demonstrate example, the used contrast are :
Mean
contrast to derive its sensitivitiesQuantile
contrast to derive sensitivities for some specific quantile levelsMean
contrast to derive sensitivities for some specific threshold values
In [4]:
sam = pygosa.MeanSensitivities(mcsp)
factors_m = sam.compute_factors()
fig, ax = sam.boxplot()
In [5]:
figure = pygosa.plot_mean_sensitivities(sam,set_labels=True)
In [6]:
saq = pygosa.QuantileSensitivities(mcsp)
factors_q = [saq.compute_factors(alpha=q) for q in [0.05, 0.25, 0.50, 0.75, 0.95]]
fig, ax = saq.boxplot()
In [7]:
figure = pygosa.plot_quantiles_sensitivities(saq,set_labels=True)
In [8]:
sap = pygosa.ProbabilitySensitivities(mcsp)
factors_p = [sap.compute_factors(threshold=v) for v in [-2.5, 0, 2.5, 7.0, 7.85]]
fig, ax = sap.boxplot(threshold=7.85)
In [9]:
figure = pygosa.plot_probability_sensitivities(sap, set_labels=True)