2.3.9. sdepy.true_wiener_source¶
-
class
sdepy.true_wiener_source(*, paths=1, vshape=(), dtype=None, corr=None, rho=None, rtol='max', t0=0.0, z0=0.0)[source]¶ dw, source of standard Wiener process (brownian motion) increments with memory.
Parameters: - paths, vshape, dtype, corr, rho
See
wiener_sourceclass documentation.- rtol, t0, z0
See
true_sourceclass documentation.
Returns: - array
Once instantiated as
dw,dw(t)returnsz0plus a realization of the standard Wiener process increment from timet0tot, anddw(t, dt)returnsdw(t + dt) - dw(t). The returned values follow a probability distribution conditional on values realized in previous calls.
Notes
For time-independent correlations, as well as for correlations that depend linearly on
t, the resultingw(t)is exact, as far as it can be within the accuracy of the pseudo-random normal variate generator of NumPy. Otherwise, mind running a first evaluation ofw(t)on a sequence of consecutive closely spaced time points in the region of interest.Given
t1 < s < t2, the value ofw(s)conditional onw(t1)andw(t2)is computed as follows.Let
AandBbe respectively the time integral ofcorr(t)betweent1ands, and betweensandt2, such that:A + Bis the expected covariance matrix ofw(t2) - w(t1),Ais the expected covariance matrix ofw(s) - w(t1),Bis the expected covariance matrix ofw(t2) - w(s).
Let
Z = B @ np.linalg.inv(A + B), and letybe a random normal variate, independent fromw(t1)andw(t2), with covariance matrixZ @ A(note that the latter is a symmetric matrix, as a consequence of the symmetry ofAandB).Then, the follwing expression provides for a
w(s)with the needed correlations, and withw(s) - w(t1)independent fromw(t1),w(t2) - w(s)independent fromw(s):w(s) = Z @ w(t1) + (1 - Z) @ w(t2) + yThis is easily proved by direct computation of the relevant correlation matrices, and by using the fact that the random variables at play are jointly normal, and hence lack of correlation entails independence.
Note that, when invoking
w(s),Ais approximated ascorr((t1+s)/2)*(s-t1), andBis approximated ascorr(s+t2)/2)*(t2-s).Attributes: Methods
See source and true_source methods.