2.2.1. sdepy.process

class sdepy.process(t=0., *, x=None, v=None, c=None, dtype=None)[source]

Array representation of a process (a subclass of numpy.ndarray).

If p is a process instance, p[i, ..., k] is the value that the k-th path of the represented process takes at time p.t[i]. The first and last indexes of p are reserved for the timeline and paths respectively. A process should contain no less than 1 time point and 1 path. Zero or more middle indexes refer to the values that the process takes at each given time and path.

If p has N time points, paths is its number of paths and vshape is the shape of its values at any given time point and path, then p.shape is (N,) + vshape + (paths,). N, vshape, paths are inferred at instantiation from the shape of t and x, v or c parameters.

Parameters:
t : array-like

Timeline of the process, as a one dimensional array with shape (N,), in increasing order. Defaults to 0.

x : array-like, optional

Values of the process along the timeline and across paths. Should broadcast to (N,) + vshape + (paths,). The shapes of t and of the firs index of x must match. One and only one of x, v, c must be provided upon process creation, as a keyword argument.

v : array-like, optional

Values of a deterministic process along the timeline. Should broadcast to (N,) + vshape. The shapes of t and of the firs index of v must match.

c : array-like, optional

Value of a constant, single-path process, with shape vshape. Each time point of the resulting process contains a copy of c.

dtype : data-type, optional

Data-type of the values of the process. x, v or c will be converted to dtype if need be.

Notes

A reference and not a copy of t, x, v, c is stored if possible.

A process is a subclass of numpy.ndarray, where its values as an array are the process values along the timeline and across paths. All numpy.ndarray methods, attributes and properties are guaranteed to act upon such values, as would those of the parent class. Such no overriding commitment is intended to safeguard predictablity of array operations on process instances; process-specific functionalities are delegated to process-specific methods, attributes and properties.

A process with a single time point is assumed to be constant.

Processes have the __array_priority__ attribute set to 1.0 by default. Ufuncs acting on a process, or on a process and an array, or on different processes sharing the same timeline, or on different processes one of which is constant, return a process with the timeline of the original process(es) passed as a reference. Ufuncs calls on different processes fail if non constant processes do not share the same timeline (interpolation should be handled explicitly), or in case broadcasting rules would result in mixing time, values and/or paths axes.

Let p be a process instance. Standard numpy indexing acts on the process values and returns numpy.ndarray instances: in fact, p[i] is equivalent to p.x[i], i.e. the same as p.view(numpy.ndarray)[i]. Process-specific indexing is addressed via the following syntax, where i can be an integer, a multi-index or smart indexing reference consistent with the process shape:

  • p['t', i] : timeline indexing, roughly equivalent to process(t=p.t[i], x=p.x[i, ..., :])
  • p['v', i] : values indexing, roughly equivalent to process(t=p.t, x=p.x[:, i, :])
  • p['p', i] : paths indexing, roughly equivalent to process(t=p.t, x=p.x[:, ..., i])
Attributes:
x

Process values, viewed as a numpy.ndarray.

paths

Number of paths of the process (coincides with the size of the last dimension of the process).

vshape

Shape of the values of the process.

tx

Timeline of the process, reshaped to be broadcastable to the process values and paths across time.

dt

Process timeline increments, as returned by numpy.diff.

dtx

Process timeline increments, as returned by numpy.diff, reshaped to be broadcastable to the process values.

t : array

Stores the timeline of the process.

interp_kind : str

Stores the default interpolation kind, passed upon interpolation (interp and __call__ methods) to scipy.interpolate.interp1d unless a specific kind is provided. Defaults to the class attribute of the same name, initialized to 'linear'. Note that ufuncs and methods, when returning new processes, do not preserve the interp_kind attribute, which falls back on the class default and should be set explicitly again if needed.

Methods

interp(*[, kind]) Interpolation in time of the process values.
__call__(s[, ds, kind]) Interpolation in time of process values or increments.
__getitem__(key) See documentation of the process class.
rebase(t, *[, kind]) Change the process timeline to t, using interpolation.
shapeas(vshape_or_process) Reshape process values according to the given target shape.
pcopy(**args) Copy timeline and values of the process (args are passed to numpy.ndarray.copy).
xcopy(**args) Copy values of the process, share timeline (args are passed to numpy.ndarray.copy).
tcopy(**args) Copy timeline of the process, share values.
pmin([out]) One path process exposing for each time point the minimum process value attained across paths.
pmax([out]) One path process exposing for each time point the maximum process value attained across paths.
psum([dtype, out]) One path process exposing for each time point the sum of process values across paths.
pmean([dtype, out]) One path process exposing for each time point the mean of process values across paths.
pvar([dtype, out, ddof]) One path process exposing for each time point the variance of process values across paths.
pstd([dtype, out, ddof]) One path process exposing for each time point the standard deviation of process values across paths.
vmin([out]) Process exposing for each time point and path the minimum of process values.
vmax([out]) Process exposing for each time point and path the maximum of process values.
vsum([dtype, out]) Process exposing for each time point and path the sum of process values.
vmean([dtype, out]) Process exposing for each time point and path the mean of process values.
vvar([dtype, out, ddof]) Process exposing for each time point and path the variance of process values.
vstd([dtype, out, ddof]) Process exposing for each time point and path the standard deviation of process values.
tmin([out]) Constant process exposing for each path the minimum process value attained along time.
tmax([out]) Constant process exposing for each path the maximum process value attained along time.
tsum([dtype, out]) Constant process exposing for each path the sum of process values along time.
tmean([dtype, out]) Constant process exposing for each path the mean of process values along time.
tvar([dtype, out, ddof]) Constant process exposing for each path the variance of process values along time.
tstd([dtype, out, ddof]) Constant process exposing for each path the standard deviation of process values along time.
tdiff([dt_exp, fwd]) Process increments along the timeline, optionally weighted by time increments.
tder() Forward looking derivative of the given process, linearly interpolated between time points.
tint() Integral of the given process, linearly interpolated between time points.
chf([t, u]) Characteristic function of the probability distribution of process values.
cdf([t, x]) Cumulative probability distribution function of process values.