VectorProcess

class samplepaths.multivariate.VectorProcess(*, t=1.0, rng=None)[source]

Bases: BaseTimeProcess

Base class of the processes with several components.

A realization is a two-dimensional array with one component per row and n + 1 values per component, at the times given by times. The names of the components are in components, in the order of the rows. sample_paths returns a three-dimensional array of shape (paths, components, n + 1).

Parameters:
  • t (float) – the right hand endpoint of the time interval \([0,t]\) for the process

  • rng (Generator | None) – a custom random number generator

components: tuple[str, ...] = ()

Names of the components, in the order of the rows of a realization.

sample(n)[source]

Generate a realization.

Parameters:

n (int) – the number of increments to generate

Returns:

the realization

Return type:

NDArray[float64]

sample_at(times)[source]

Generate a realization at specified times.

Parameters:

times (NDArray[float64]) – a vector of increasing time values at which to generate the realization

Returns:

the realization

Raises:

NotImplementedError – if the process does not support sampling at specified times

Return type:

NDArray[float64]

sample_paths(n, paths, workers=1)[source]

Generate several independent realizations.

Parameters:
  • n (int) – the number of increments of each realization

  • paths (int) – the number of realizations

  • workers (int) – the number of threads to use

Returns:

a three-dimensional array of shape (paths, components, n + 1)

Return type:

NDArray[float64]

property n: int

Number of increments of the most recent realization.

Raises:

RuntimeError – if no realization has been generated yet

property rng: Generator

Random number generator used by the process.

This is the generator passed at instantiation, or the package default samplepaths.random.generator when none was given.

set_times(n)

Generate the time values of n increments on [0, t].

Parameters:

n (int) – the number of increments

Returns:

True if the time values changed, False if they were already generated for the same arguments

Return type:

bool

set_times_with_t(end_t, n)

Generate the time values of n increments on [0, end_t].

Parameters:
  • end_t (float) – the right hand endpoint of the time interval

  • n (int) – the number of increments

Returns:

True if the time values changed, False if they were already generated for the same arguments

Return type:

bool

property t: float

End time of the process.

property times: ndarray[tuple[Any, ...], dtype[float64]]

Time values of the most recent realization.

Holds n + 1 equally spaced values on the interval \([0,t]\).

Raises:

RuntimeError – if no realization has been generated yet