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
SDEclass documentation.This class encapsulates SDE integration methods, and cooperates with the
SDEclass, that should always have precedence in method resolution order. As long as the respective APIs are complied with, a new integrator stated as anintegratorsubclass will interoperate with existing SDEs (as described bySDEsubclasses), and a new SDE will interoperate with existing integrators.Parameters: - paths, xshape, wshape, dtype, steps, i0, info, getinfo
See
paths_generatorclass 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 cooperatingSDEsubclass and the chosen integration method. Defaults to a process ofnumpy.nanalong the given timeline.
See also
Notes
The equation to be integrated is exposed to the integration algorithm in a standardized form, via methods
AanddZdelegated to a cooperatingSDEclass. 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
nextmethod to thepaths_generatorparent class.If the
getinfoattribute is set toTrue, at each integration step the following items are added to theitervarsdictionary, 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_ttolast_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(t, x)Value of the SDE terms at time t and process value x. dZ(t, dt)Value of the SDE differentials at time t, for time increment dt. next()Perform an integration step with the requested method. euler_next()Euler-Maruyama integration step.