MixedPoissonProcess

class samplepaths.continuous.MixedPoissonProcess(*, rate_func, rate_args=None, rate_kwargs=None, rng=None)[source]

Bases: PoissonProcess

Mixed poisson process.

../../_images/mixed_poisson_process.png

A mixed poisson process is a Poisson process for which the rate is a scalar random variate. The sample method will generate a random variate for the rate before generating a Poisson process realization with the rate. A Poisson process with rate \(\lambda\) is a count of occurrences of i.i.d. exponential random variables with mean \(1/\lambda\). Use the rate attribute to get the most recently generated random rate.

Parameters:
  • rate_func (Callable[[...], float]) – a callable to generate variates of the random rate

  • rate_args (tuple[float, ...] | None) – positional args for rate_func

  • rate_kwargs (dict[str, Any] | None) – keyword args for rate_func

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

property rate_func: Callable[[...], float]

Current rate’s distribution.

property rate_args: tuple[float, ...]

Positional arguments for the rate function.

property rate: float

Rate parameter.

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.

sample_paths(n, paths, workers=1)

Generate several independent realizations at once.

The realizations have the distribution of those of sample(). Many processes generate them together, which is much faster than calling sample() repeatedly. For a given seed, the values differ from those of repeated calls to sample(), because the random numbers are drawn in a different order.

With workers greater than one, the realizations are generated on that many threads, each with its own generator derived from the generator of the process. The result is reproducible for a given seed and number of workers, and differs between numbers of workers. Processes which generate their realizations one after the other ignore workers.

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 two-dimensional array with one realization per row

Return type:

NDArray[float64] | NDArray[int64]

property rate_kwargs: dict[str, Any]

Keyword arguments for the rate function.

sample(n)[source]

Generate a realization.

Parameters:

n (int) – the number of increments to generate

Returns:

the realization. Processes with integer values, such as the state of a Markov chain, return an array of integers.

Return type:

NDArray[float64]

sample_with_length(length)[source]

Generate the arrival times over a length of time.

Parameters:

length (float) – the length of time to simulate

Returns:

the arrival times, starting at zero and ending with the first arrival after length

Return type:

NDArray[float64]