Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a python module to solve/integrate a system of stochastic differential equations?

I have a system of stochastic differential equations that I would like to solve. I was hoping that this issue was already address. I am a bit concerned about constructing my own solver because I fear my solver would be too slow, and there could be the issues with numerical stability.

Is there a python module for such problems?

If not, is there a standard approach for solving such systems.

like image 412
CraigF Avatar asked Jan 29 '13 23:01

CraigF


People also ask

Can you solve differential equations in Python?

Differential equations are solved in Python with the Scipy. integrate package using function odeint or solve_ivp. t: Time points at which the solution should be reported. Additional internal points are often calculated to maintain accuracy of the solution but are not reported.

How do you integrate a differential function?

We multiply both sides of the differential equation by the integrating factor I which is defined as I = e∫ P dx. ⇔ Iy = ∫ IQ dx since d dx (Iy) = I dy dx + IPy by the product rule. As both I and Q are functions involving only x in most of the problems you are likely to meet, ∫ IQ dx can usually be found.

How is stochastic equation of information is solved?

One approach for solving the stochastic differential equation given by equation (6.2) is using the Feyman-Kac theorem. More precisely, by the change of variable method,23 a partial differential equation equivalent to the stochastic differential equation (6.2) can be achieved.


2 Answers

There is one: http://diffusion.cgu.edu.tw/ftp/sde/

Example from the site:

""" add required Python packages """
from pysde import *
from sympy import *
""" Variables acclaimed """
x,dx=symbols('x dx')
r,G,e,d=symbols('r G epsilon delta')
""" Solve Kolmogorov Forward Equation """
l=sde.KolmogorovFE_Spdf(r*(G-x),e*x*(1-x),0,1)
sol=l.subs({e:r*d})

pprint(sol)
like image 174
Kabie Avatar answered Sep 19 '22 18:09

Kabie


The link in the accepted answer no longer functions. There is also sdeint:

https://pypi.org/project/sdeint/#description

Which was released a few years after the accepted answer and looks to be in semi-active development. A second example in the documentation has a system of SDE with constant coefficients. I am unsure if they have support for more complex SDE systems.

like image 29
jman Avatar answered Sep 19 '22 18:09

jman