how to solve the SDE(stochastic deferential equations) and what method do you use on python?

701 views
Skip to first unread message

red...@gmail.com

unread,
Mar 3, 2016, 10:06:44 PM3/3/16
to Brian
Dear. Brian development team,

Hello! I'm developing simulator based on python which can simulate with motoneuron, and i want to integrate some differential equations every integration step.

But, i have a problem with stochastic differential equation in this step.

so, May I ask how did you solve the SDE(stochastic deferential equations) and what tools or method did you use on python?

I found your paper, Goodman, Dan, and Romain Brette. "Brian: a simulator for spiking neural networks in Python." (2008).

In this paper, you say "Stochastic differential equations are integrated with Euler updates (adding normally distributed random numbers every time step)."

But i don't know exactly what is the Euler update. (is it mean Euler-maruyama method?)

I also read the BRIAN documentation, to look for these integrate method, how to implement in detail, But, i didn't find.


what i want to ask is that

1. Is it possible to integrate SDE with 'SciPy' python library? i use this tool. (it doesn't work if i add the random variable function to ordinary differential equation.)

2. If not, what method do you use? (with integration on other ordinary differential equations.)

3. Is there any advise?


Thank you for reading.



Marcel Stimberg

unread,
Mar 7, 2016, 8:06:57 AM3/7/16
to brians...@googlegroups.com
Hi,

in Brian 1, SDE's are not dealt with very well. For an equation "dx/dt =
[...] + sigma * xi", the equation is integrated with whatever numerical
integration method is chosen for the non-stochastic part and then
sigma*sqrt(dt)*N, where N is a random number drawn from a standard
normal distribution, is added. This corresponds to the Euler-Maruyama
method (if the main method is "euler"), but only for additive noise (or
multiplicative noise under the Itô calculus interpretation).

I'd recommend to instead have a look at Brian 2 (which is still in
"beta", but we'll have a 2.0 release soon), where this is handled more
rigorously: http://brian2.readthedocs.org
The documentation for stochastic equations is not very complete at the
moment, but have a look at
http://brian2.readthedocs.org/en/2.0b4/advanced/state_update.html and at
our paper
(http://journal.frontiersin.org/article/10.3389/fninf.2014.00006/full)
to get an idea of how the mechanism works.
For stochastic equations, you currently have the choice to use the
Euler-Maruyama ("euler") method (for additive noise only), the
Euler-Heun method ("heun") or the derivative-free Milstein method
("milstein"). The latter two can be used for multiplicative noise as
well (under the Stratonovich interpretation).

In the paper I linked above, you'll find explanations about our general
approach to solving differential equations numerically. Unfortunately
this approach is at the moment not compatible with the use of solvers
from other libraries like scipy. We want to make the system more
flexible in the future, but this is more of a longer term project.

Hope that helps, best
Marcel

red...@gmail.com

unread,
Mar 10, 2016, 4:32:11 AM3/10/16
to Brian
Dear. Marcel

Thank you for your reply!

It's very helpful for me.

and i also wonder why BRIAN chose only the Euler-Maruyama method for the 'additive noise'.

if i need the more precision of SDE solution with the 'additive noise', 

Is it good to use other method instead of the euler method?



2016년 3월 7일 월요일 오후 10시 6분 57초 UTC+9, Marcel Stimberg 님의 말:

Marcel Stimberg

unread,
Mar 14, 2016, 8:41:55 AM3/14/16
to brians...@googlegroups.com
Hi,

> and i also wonder why BRIAN chose only the Euler-Maruyama method for
> the 'additive noise'.
I am not sure I understand. The Euler-Maruyama method is valid for
additive noise or for multiplicative noise under the Itô calculus --
since we use the Stratonovitch interpretation in Brian 2 (which makes
more sense for a physical system), you are not allowed to use this
algorithm for multiplicative noise but it is used for additive noise.

> if i need the more precision of SDE solution with the 'additive noise',
>
> Is it good to use other method instead of the euler method?
if you have additive noise with a constant coefficient (e.g. something
like "... + sigma * tau**-0.5*xi"), then all the three methods are
equivalent. Their accuracy scales linearly with the time step. If you
want, say, 10 times more precision then you should reduce the time step
by a factor of 10 as well.

Best,
Marcel

red...@gmail.com

unread,
Mar 22, 2016, 12:41:31 AM3/22/16
to Brian
Thank you.

it is helpful for me to have concept about SDE solver.
Reply all
Reply to author
Forward
0 new messages