[SciPy-User] Fitting a system of ODEs to data

Sebastian Walter sebastian.walter at gmail.com
Thu Sep 10 14:28:20 EDT 2009


encountering many local optima may as well be an artifact of
inaccurate derivative approximations (gradient, hessian).
A long valley with steep walls often converges only to the bottom of
the valley but due to the inaccurate gradient it can't find a descent
direction anymore.

The get the derivative information you can do the following:
define the  variational ODE, i.e. if your ODE is

d/dt x  = f(t,x,p)
x(0) = x0(p)

Then the variational ODE is

d/dt x  = f(t,x,p)
d/dt x_p = f_x(t,x,p) x_p + f_p(t,xp)
x(0) = x0(p)
x_p(0) = x0_p(p)

where x_p := d/dp x

The evaluation can then be done by the standard scipy ode solvers.
Input for scipy.optimize.leastsq is the vector of measurements
y = [y(t_1), y(t_2), ...., ] taken at the  measurement times
ts = [t_1, t_2, ....].

You can also now define a function Dfun that returns
the Jacobian y_p.

This should work much better than the version without derivative information.

There is also an adjoint ODE solver in Python that would be preferable if
the number of parameters is large, but I can't recall the name of the package
right now....


Sebastian








On Thu, Sep 10, 2009 at 7:13 PM, Robert Kern <robert.kern at gmail.com> wrote:
> On Thu, Sep 10, 2009 at 12:08, C. Campbell<lujitsu at hotmail.com> wrote:
>> Thanks, both of you. I actually had tried something similar to what you both
>> suggested, but it didn't seem like the function was converging to a
>> solution, so I (incorrectly!) assumed the problem must be with the ODE
>> nature of my system.
>
> It might be, sort of. You will probably have to have a good guess of
> the parameters. The functions generated by many ODEs tend to be less
> suitable for fitting than other functions of interest. You may
> encounter many local optima. It would be worthwhile to do a bit of
> brute force searching through your parameter space to get a good
> starting point or use a global optimizer.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list