When you write a program with lots of code, its difficult to find out which values have a big influence of your final result. In my case i have got a few differential equations which I solve with odeint. It would take a lot of time to find out which values have a big influence on my result (velocity). Is there any Tool in python to analyze your values or does someone have any idea?
Thanks for your help.
[Edit]
MathBio: "In general a sensitivity analysis is what you would do. "
@MathBio I read a few blogs about SALib now(SALib Guide) and tried to write a "easier" test program to solve differential equations. Below you see my written program: I get the error-message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/Tim_s/Desktop/Workspace/test/TrySALib.py", line 44, in <module>
Y = Odefunk(param_values)
File "C:/Users/Tim_s/Desktop/Workspace/test/TrySALib.py", line 24, in Odefunk
dT=odeint(dTdt,T0,t,args=(P,))
File "C:\Python27\lib\site-packages\scipy\integrate\odepack.py", line 148, in odeint
ixpr, mxstep, mxhnil, mxordn, mxords)
File "C:/Users/Tim_s/Desktop/Workspace/test/TrySALib.py", line 17, in dTdt
dT[0]=P[0]*(T[1]-T[0])+P[2]
IndexError: tuple index out of range
Here the code:
from SALib.sample import saltelli
from SALib.analyze import sobol
import numpy as np
from pylab import *
from scipy.integrate import odeint
Tu=20.
t=linspace(0,180,90)
def dTdt(T,t,P):# DGL
dT=zeros(2)
dT[0]=P[0]*(T[1]-T[0])+P[2]
dT[1]=P[1]*(Tu-T[1])+P[0]*(T[0]-T[1])
return dT
T0=[Tu,Tu]
def Odefunk(values):
for P in enumerate(values):
dT=odeint(dTdt,T0,t,args=(P,))
return dT
# Define the model inputs
problem = {
'num_vars': 3,
'names': ['P0', 'P1', 'P2'],
'bounds': [[ 0.1, 0.2],
[ 0.01, 0.02],
[ 0.5, 1]]
}
# Generate samples
param_values = saltelli.sample(problem, 1000, calc_second_order=True)
# Run model (example)
Y = Odefunk(param_values)
# Perform analysis
Si = sobol.analyze(problem, Y, print_to_console=False)
# Print the first-order sensitivity indices
print Si['S1']