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) returns z0 plus a realization of the standard Wiener process increment from time t0 to t, and dw(t, dt) returns dw(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 resulting w(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 of w(t) on a sequence of consecutive closely spaced time points in the region of interest.

Given t1 < s < t2, the value of w(s) conditional on w(t1) and w(t2) is computed as follows.

Let A and B be respectively the time integral of corr(t) between t1 and s, and between s and t2, such that:

  • A + B is the expected covariance matrix of w(t2) - w(t1),
  • A is the expected covariance matrix of w(s) - w(t1),
  • B is the expected covariance matrix of w(t2) - w(s).

Let Z = B @ np.linalg.inv(A + B), and let y be a random normal variate, independent from w(t1) and w(t2), with covariance matrix Z @ A (note that the latter is a symmetric matrix, as a consequence of the symmetry of A and B).

Then, the follwing expression provides for a w(s) with the needed correlations, and with w(s) - w(t1) independent from w(t1), w(t2) - w(s) independent from w(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 as corr((t1+s)/2)*(s-t1), and B is approximated as corr(s+t2)/2)*(t2-s).

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

See source and true_source methods.