3.3.1. sdepy.source¶
-
class
sdepy.source(*, paths=1, vshape=(), dtype=None, rng=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.- rng : numpy.random.Generator, or numpy.random.RandomState, or None
Random numbers generator used. If
None, defaults tosdepy.infrastructure.default_rng, a global variabile initialized on import tonumpy.random.default_rng().
Returns: - array
Once instantiated as
dz,dz(t, dt)returns a random realization of the stochasticity source increments from timetto timet + dt, with shape(t + dt).shape + vshape + (paths,). For sources with memory (true_sourceclass and subclasses),dz(t)returns the realized value at timetof 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 ofnumpy.nan.
Notes
Any callable object
dz(t, dt), with attributespathsandvshape, returning arrays broadcastable to shapet_shape + vshape + (paths,), wheret_shapeis the shape oftand/ordt, complies with thesourceprotocol. 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.processinstances, in particular, may be used as stochasticity sources.When calling
dz(t, dt),tand/ordtcan take any shape.Attributes: rngRead-only access to the random number generator used by the stochasticity source.
sizeReturns the number of stored scalar values from previous evaluations, or 0 for sources without memory.
tReturns 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.