2.3.1. sdepy.source

class sdepy.source(*, paths=1, vshape=(), dtype=None)[source]

Base class for stochasticity sources.

Parameters:
paths : int

Number of paths (last dimension) of the source realizations.

vshape : tuple of int

Shape of source values.

dtype : data-type

Data type of source values. Defaults to None.

Returns:
array

Once instantiated as dz, dz(t, dt) returns a random realization of the stochasticity source increments from time t to time t + dt, with shape (t + dt).shape + vshape + (paths,). For sources with memory (true_source class and subclasses), dz(t) returns the realized value at time t of the source process, according to initial conditions set at instantiation. The definition of source specific parameters, and computation of actual source realizations, are delegated to subclasses. Defaults to an array of numpy.nan.

Notes

Any callable object dz(t, dt), with attributes paths and vshape, returning arrays broadcastable to shape t_shape + vshape + (paths,), where t_shape is the shape of t and/or dt, complies with the source protocol. Such object may be passed to any of the process realization classes, to be used as a stochasticity source in integrating or computing the relevant SDE solution. process instances, in particular, may be used as stochasticity sources.

When calling dz(t, dt), t and/or dt can take any shape.

Attributes:
size

Returns the number of stored scalar values from previous evaluations, or 0 for sources without memory.

t

Returns a copy of the time points at which source values have been stored from previous evaluations, as an array, or an empty array for sources without memory.

Methods

__call__(t[, dt]) Realization of stochasticity source values or increments.