2.3.2. sdepy.wiener_source¶
-
class
sdepy.wiener_source(*, paths=1, vshape=(), dtype=None, corr=None, rho=None)[source]¶ dw, a source of standard Wiener process (Brownian motion) increments.
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.- corr : array-like, or callable, or None
Correlation matrix of the standard Wiener process increments, possibly time-dependent, or
Nonefor no correlations, or for correlations specified by therhoparameter. If notNone, overridesrho. Ifcorris a square matrix of shape(M, M), or callable withcorr(t)evaluating to such matrix, the last dimension of the source values must be of sizeM(vshape[-1] == M), and increments along the last axis of the source values will be correlated accordingly.- rho : array-like, or callable, or None
Correlations of the standard Wiener process increments, possibly time-dependent, or
Nonefor no correlations. Ifrhois scalar, or callable withrho(t)evaluating to a scalar,M=2is assumed, andcorr=((1, rho), (rho, 1)). Ifrhois a vector of shape(K,), or a callable withrho(t)evaluating to such vector,M=2*Kis assumed, and theMsource values along the lastvshapedimension are correlated so thatrho[i]correlates thei-th andK+i-th values, other correlations being zero (corr = array((I, R), (R, I))whereI = numpy.eye(K)andR = numpy.diag(rho)).
Returns: - array
Once instantiated as
dw,dw(t, dt)returns a random realization of standard Wiener process increments from timetto timet + dt, with shape(t + dt).shape + vshape + (paths,). The increments are normal variates with mean 0, either independent with standard deviationsqrt(dt), or correlated with covariance matrixcorr*dt, orcorr(t + dt/2)*dt(the latter approximates the integral ofcorr(t)fromttot + dt).
See also
Notes
Realizations across different
tand/ordtarray elements, and/or across different paths, and/or along axes of the source values other than the last axis ofvshape, are independent.corrshould be a correlation matrix with unit diagonal elements and off-diagonal correlation coefficients, not a covariance matrix.corrandrhovalues with a trailing one-dimensional paths axis are accepted, of shape(M, M, 1)or(M/2, 1)respectively. This last axis is ignored: this allows for deterministicprocessinstances (single path processes) to be passed as validcorrorrhovalues. Path dependentcorrandrhoare not supported.For time-dependent correlations,
dw(t, dt)approximates the increments of a processw(t)obeying the SDEdw(t) = D(t)*dz(t), wherez(t)are standard uncorrelated Wiener processes, andD(t)is a time-dependent matrix such thatD(t) @ (D(t).T) == corr(t). Note that, given any two time pointssandt > s, by the Ito isometry the expectation value of(w(t)-w(s))[i] * (w(t)-w(s))[j], i.e. thei,jelement of the covariance matrix of increments ofwfromstot, equals the integral ofcorr(u)[i, j]indufromstot.For time-independent correlations, as well as for correlations that depend linearly on
t, the resultingdw(t, dt)is exact, as far as it can be within the accuracy of the pseudo-random normal variate generator of NumPy. Otherwise, mind using small enoughdtintervals.Attributes: - corr : array, or callable
Stores the correlation matrix used computing increments. May expose either a reference to
corr, if provided explicitly, or an appropriate object, in caserhowas specified.
Methods
__call__(t, dt)See wiener_source class documentation.