[SciPy-user] Estimation of parameters while fitting data

Rob Clewley rob.clewley at gmail.com
Mon Mar 31 16:19:48 EDT 2008


Hi Doreen,

If you send me your code which you tried using PyDSTool, I will
happily advise you on how to fix it. I'm sure it will be possible for
me to fix it!
-Rob

On Mon, Mar 31, 2008 at 4:09 PM, Doreen Mbabazi <doreen at aims.ac.za> wrote:
> 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 at scipy.org
>  > http://projects.scipy.org/mailman/listinfo/scipy-user
>  >
>
>
>
>
>  _______________________________________________
>  SciPy-user mailing list
>  SciPy-user at scipy.org
>  http://projects.scipy.org/mailman/listinfo/scipy-user
>



-- 
Robert H. Clewley, Ph. D.
Assistant Professor
Department of Mathematics and Statistics
Georgia State University
720 COE, 30 Pryor St
Atlanta, GA 30303, USA

tel: 404-413-6420 fax: 404-651-2246
http://www.mathstat.gsu.edu/~matrhc
http://brainsbehavior.gsu.edu/



More information about the SciPy-User mailing list