mattja / sdeint

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

Implementation of first passage times #22

Open juanracasti opened 1 year ago

juanracasti commented 1 year ago

First of all, thanks a lot for the package, it's very useful!

I was wondering whether the following application could be a relevant addition for sdeint: In several fields, including neuroscience and decision making, it's often of interest to calculate the first passage time of (simple) stochastic processes reaching a certain bound or bounds (usually constant for simplicity although it doesn't need to be). You might have heard about the DDM model and variants.

Your functions such as itoSRI2() are very useful to calculate the trajectories of this process, but one still needs to evaluate when the trajectories reach the bound for the first time. To do this, most commonly one integrates trajectories until a fixed maximum (long) time Tmax, and then finds when the trajectories reach the bound. This is not very efficient, as many trajectories will reach the bound much earlier than Tmax. The other alternative is to evaluate the bound crossing at every time step of the trajectory, but since this is outside of the itoSRI2() function, it's also probably not efficient (multiple calls to the function with subsequent overhead, etc.)

I was wondering if it would be worthwhile to implement a method in which you pass already the bound function(s), and it returns directly the first passage time, and which bound was reached first (in case of multiple), all from within the itoSRI2() akin method. I think it would be valuable for a lot of researchers that currently are using the first technique described above, or implementing their own (and likely inefficient) Euler-Maruyama simulations.