3.3.4. sdepy.cpoisson_source

class sdepy.cpoisson_source(*, paths=1, vshape=(), dtype=None, rng=None, dn=None, ptype=<class 'int'>, lam=1.0, y=None)[source]

dj, a source of compound Poisson process increments (jumps).

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.

rng : numpy.random.Generator, or numpy.random.RandomState, or None

Random numbers generator used. If None, defaults to sdepy.infrastructure.default_rng, a global variabile initialized on import to numpy.random.default_rng(). Used to generate Poisson process increments (unless dn is explicilty given with its own dn.rng) and y random variates.

dn : source or source class, or None

Underlying source of Poisson process increments. If a class, it is used to instantiate the source; if a source, it is used as it is, overriding the given ptype and lam parameters. If None, it is instantiated as a sdepy.poisson_source.

ptype : data-type

Data type of Poisson process increments. Defaults to int.

lam : array-like, or callable

Intensity of the underlying Poisson process, possibly time-dependent. See poisson_source class documentation.

y : distribution, or callable, or None

Distribution of random variates to be compounded with the Poisson process increments, possibly time-dependent. May be any scipy.stats distribution instance, or any object exposing an rvs method to be invoked with signature rvs(size=output_shape, random_state=rng) to generate independent random variates with given shape and generator, or a callable with y(t) evaluating to such object. The following preset distributions may be specified, possibly with time-varying parameters:

  • y=norm_rv(a, b) - normal distribution with mean a and standard deviation b.
  • y=uniform_rv(a, b) - uniform distribution between a and b.
  • y=exp_rv(a) - exponential distribution with scale a.
  • y=double_exp_rv(a, b, pa) - double exponential distribution, with scale a with probability pa, and -b with probability 1 - pa.

where a, b, pa are array-like with values in the appropriate domains, broadcastable to a shape vshape + (paths,), or callables with a(t), b(t), pa(t) evaluating to such arrays. If None, defaults to uniform_rv(a=0, b=1).

Returns:
array

Once instantiated as dj, dj(t, dt) returns a random realization of compound Poisson process increments from time t to time t + dt, with shape (t + dt).shape + vshape + (paths,). The increments are independent compound Poisson variates, consisting of the sum of N independent y or y(t + dt/2) variates, where N is a Poisson variate with mean lam*dt, or lam(t + dt/2)*dt (approximates each variate being taken from y at the time of the corresponding Poisson process event).

Notes

Preset distributions norm_rv, uniform_rv, exp_rv, double_exp_rv behave as follows:

  • If all parameters are array-like, return an object with an rvs method as described above, and with methods mean, std, var, exp_mean with signature (), returning the mean, standard deviation, variance and mean of the exponential of the random variate.
  • If any parameter is callable, returns a callable y such that y(t) evaluates to the corresponding distribution with parameter values at time t.

To compound the Poisson process increments with a function f(z), or time-dependent function f(t, z), of a given random variate z, one can pass y=rvmap(f, z) to compound_poisson.

[ToDo: make a note on martingale correction using exp_mean]

Attributes:
y : distribution, or callable

Stores the distribution used computing the Poisson process increments.

dn_value : array of int

After each realization, this attribute stores the underlying Poisson process increments.

y_value : list of array

After each realization, this attribute stores the underlying y random variates.

Methods

__call__(t, dt) See cpoisson_source class documentation.