![](https://secure.gravatar.com/avatar/2d12790c24393413697e9189145cad06.jpg?s=120&d=mm&r=g)
Hi, Thanks, I tried to do that(by taking err = V-f(y,t,p)[2]) while defining the function residuals but the trouble is that actually f(y,t,p) calculates value of y at t0 so it cannot help me. What I want are the third values from y(y[i][2]). Below I have tried to do that but that gives particular values of y so my parameters are not optimized. def residuals(p, V, t): """The function is used to calculate the residuals """ for i in range(len(t)): err = V-y[i][2] return err #Function defined with y[0]=T,y[1]=T*,y[2] = V,lamda = p[0],d = p[1], k=p[2],delta=p[3], pi = p[4], c = p[5] initial_y = [10,0,10e-6] # initial conditions T(0)= 10cells , T*(0)=0, V(0)=10e-6 p is the list of parameters that are being estimated (lamda,d,k,delta,pi,c) def f(y,t,p): y_dot = [0,0,0] y_dot[0] = p[0] - p[1]*y[0] - p[2]*y[0]*y[2] y_dot[1] = p[2]*y[0]*y[2] - p[3]*y[1] y_dot[2] = p[4]*y[1] - p[5]*y[2] return y_dot y = odeint(f,initial_y,t,args=(p,)) Doreen Gabriel Gellner
I have as my fitting function a system of differential equations(3) and I am supposed to get the optimal parameters to use by fitting data to this system. I tried to use scipy.optimize.leastsq. The difficulty is with the function that calculates the difference between the data and the values from the fitting function. The result of the fitting function is a list with three values and yet I only need one of the values to be subtracted from the data value. Could you not just subtract the index of the returned value? Say it is the first value you need then just use value[0].
If not can you give a small example, it will make it easier to help.
Gabriel _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user