2.4.5. sdepy.integrate

sdepy.integrate(sde=None, *, q=None, sources=None, log=False, addaxis=False)[source]

Decorator for Ito Stochastic Differential Equation (SDE) integration.

Decorates a function representing the SDE or SDEs into the corresponding sdepy integrator.

Parameters:
sde : function

Function to be wrapped. Its signature and values should be as expected for the sde method of the sdepy.SDE or sdepy.SDEs classes.

q : int

Number of equations. If None, attempts a test evaluation of sde to find out. q=0 indicates a single equation.

sources : set

Stochasticity sources used in the equation. If None, attempts a test evaluation of sde to find out.

log : bool

Sets the log attribute for the wrapping class.

addaxis : bool

Sets the addaxis attribute for the wrapping class.

Returns:
A subclass of sdepy.SDE or sdepy.SDEs as appropriate,
and of sdepy.integrator, with the given sde
cast as its sde method.

Notes

To prevent a test evaluation of sde, explicitly provide the intended q and sources as keyword arguments to integrate(). The test evaluation is attempted as sde() and, upon failure, again as sde(1., 1.).

Examples

>>> from sdepy import integrate
>>> @integrate
... def my_process(t, x, theta=1., k=1., sigma=1.):
...     return {'dt': k*(theta - x), 'dw': sigma}
>>> P = my_process(x0=1, sigma=0.5, paths=100*1000, steps=100)
>>> x = P(timeline=(0., 0.5, 1.))
>>> x.shape
(3, 100000)