2.4.2. sdepy.integrator¶
-
class
sdepy.
integrator
(*, paths=1, xshape=(), wshape=(), dtype=None, steps=None, i0=0, info=None, getinfo=True, method='euler')[source]¶ Step by step numerical integration of Ito Stochastic Differential Equations (SDEs), intended for subclassing.
For usage, see the
SDE
class documentation.This class encapsulates SDE integration methods, and cooperates with the
SDE
class, that should always have precedence in method resolution order. As long as the respective APIs are complied with, a new integrator stated as anintegrator
subclass will interoperate with existing SDEs (as described bySDE
subclasses), and a new SDE will interoperate with existing integrators.Parameters: - paths, xshape, wshape, dtype, steps, i0, info, getinfo
See
paths_generator
class documentation.- method : string
Integration method. Defaults to
'euler'
, for the Euler-Maruyama method (at present, this single method is supported). It is stored as an attribute of the same name.
Returns: - process
Once instantiated as
p
,p(timeline)
performs the integration along the given timeline, based on parameters of instantiation, returning the resulting process as determined by the cooperatingSDE
subclass and the chosen integration method. Defaults to a process ofnumpy.nan
along the given timeline.
See also
Notes
The equation to be integrated is exposed to the integration algorithm in a standardized form, via methods
A
anddZ
delegated to a cooperatingSDE
class. The latter should take care of equation parameters, initial conditions, expected paths and shapes, and should instantiate all necessary stochasticity sources.The integration method is exposed as the
next
method to thepaths_generator
parent class.If the
getinfo
attribute is set toTrue
, at each integration step the following items are added to theitervars
dictionary, made available to subclasses to track the integration progress:last_t
: starting time point of the last integration step.last_dt
: time increment of the last integration step.last_x
: starting value of the process, at timelast_t
.last_A
: dictionary of the last computed values of the SDE terms, at timelast_t
.last_dZ
: dictionary of the last realized SDE stochasticity source values, cumulated in the interval fromlast_t
tolast_t + last_dt
.new_x
: computed value of the process, at timelast_t + last_dt
.
This becomes relevant in case the output timeline is coarse (e.g. just the initial and final time) but diagnostic information is needed about all integration steps performed (e.g., to track how often the process has changed sign, or to count the number of realized jumps).
Methods
A
(self, t, x)Value of the SDE terms at time t and process value x. dZ
(self, t, dt)Value of the SDE differentials at time t, for time increment dt. next
(self)Perform an integration step with the requested method. euler_next
(self)Euler-Maruyama integration step.