mattja / sdeint

Numerical integration of Ito or Stratonovich SDEs
GNU General Public License v3.0
154 stars 25 forks source link

Delay equations. #1

Open parenthetical-e opened 8 years ago

parenthetical-e commented 8 years ago

I'd like to brighten the possibility of integrating stochastic delay ODEs, if possible.

Can the approach used in, https://github.com/Zulko/ddeint/blob/master/ddeint/ddeint.py, be adapted for sdeint? I'm quite happy to write the code, if there's interest. Wanted to see if that looks like a viable approach. My understanding of numerical methods for stochastic ODEs is not good enough to be sure this is a sane route.

mattja commented 8 years ago

Thanks for the suggestion. That is a nice approach for DDE (using linear interpolation of history together with an existing integrator) but I think that code design can not be directly ported to the stochastic case. The design of that code allows users to provide a fairly general DDE, as the evolution function func supplied by the user can depend in arbitrary ways on the recent history. The main danger I see in directly applying that to SDDEs comes from the interpolation (when the needed history is not exactly on a time step).

I'm not expert in SDDEs, but it is possible that a heuristic adaptation of that code to the stochastic case may result in converging to the wrong path, or converging with decreasing step size more slowly than expected. Because it's possible a different interpolant is needed for the stochastic case to get the right convergence.

You can avoid this problem by restricting to SDDEs with a single discrete delay (because then you can choose a step size so that the delay is an integer times the step size. Then no interpolation is needed and the algorithms are simpler. For multiple discrete delays that is not possible, unless the ratio between delays equals a ratio of reasonably small integers, so a step size can be chosen with all delays an integer multiple of step size).

To add support for delays in sdeint, maybe the easiest case we could start with is to support the Euler-Maruyama algorithm for equations with a single discrete delay:

It is also possible to do the interpolation correctly to support more general SDDE equations, and to have faster converging algorithms. e.g.:

From these can see that it's not trivial to extend algorithms to the stochastic delay case, so best to stick to the published algorithms.