CoCalc Shared Filessalib.ipynbOpen in CoCalc with one click!
Author: Harald Schilly
Views : 52
Description: sensitivity analysis via salib in cocalc

Sensitivity Analysis via SALib

http://salib.readthedocs.io/en/latest/

In [1]:
from SALib.sample import saltelli from SALib.analyze import sobol from SALib.test_functions import Ishigami import numpy as np # Define the model inputs problem = { 'num_vars': 3, 'names': ['x1', 'x2', 'x3'], 'bounds': [[-3.14159265359, 3.14159265359], [-3.14159265359, 3.14159265359], [-3.14159265359, 3.14159265359]] } # Generate samples param_values = saltelli.sample(problem, 1000) # Run model (example) Y = Ishigami.evaluate(param_values) # Perform analysis Si = sobol.analyze(problem, Y, print_to_console=True)
Parameter S1 S1_conf ST ST_conf x1 0.307975 0.063927 0.560137 0.085162 x2 0.447767 0.054012 0.438722 0.041973 x3 -0.004255 0.053252 0.242845 0.026515 Parameter_1 Parameter_2 S2 S2_conf x1 x2 0.012205 0.086689 x1 x3 0.251526 0.103264 x2 x3 -0.009954 0.064820
In [2]:
# Print the first-order sensitivity indices print(Si['S1'])
[ 0.30797549 0.44776661 -0.00425452]
In [3]:
print(Si['ST'])
[0.56013728 0.4387225 0.24284474]
In [4]:
# second order ... print(Si['S2'])
[[ nan 0.01220462 0.25152574] [ nan nan -0.00995392] [ nan nan nan]]
In [5]:
print("x1-x2:", Si['S2'][0,1]) print("x1-x3:", Si['S2'][0,2]) print("x2-x3:", Si['S2'][1,2])
x1-x2: 0.012204615255332008 x1-x3: 0.2515257351736558 x2-x3: -0.009953919522955074
In [ ]: