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_source
class documentation.- rtol, t0, z0
See
true_source
class documentation.
Returns: - array
Once instantiated as
dw
,dw(t)
returnsz0
plus a realization of the standard Wiener process increment from timet0
tot
, 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
A
andB
be respectively the time integral ofcorr(t)
betweent1
ands
, and betweens
andt2
, such that:A + B
is the expected covariance matrix ofw(t2) - w(t1)
,A
is the expected covariance matrix ofw(s) - w(t1)
,B
is the expected covariance matrix ofw(t2) - w(s)
.
Let
Z = B @ np.linalg.inv(A + B)
, and lety
be 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 ofA
andB
).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) + y
This 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)
,A
is approximated ascorr((t1+s)/2)*(s-t1)
, andB
is approximated ascorr(s+t2)/2)*(t2-s)
.Attributes: Methods
See source and true_source methods.