Small package to enable creation of Non-homogeneous Poisson Processes.
Project description
nhpp
INSTALLATION: pip install nhpp
PURPOSE:
This package is (currently) a standalone module for generating non-homogeneous Poisson processes (nhpp). Homogeneous Poisson processes are easily generated by specifying an arrival rate, lambda, then generating samples from X ~ exp(1 / lambda). These samples indicate the inter-arrival times between events, or the delay between events.
The above case is only true when lambda is a constant. Generalizing to the case of lambda(t), a time-dependent arrival rate, is much trickier to implement. Two main approaches exist to tackle this issue: (1) relate the INTEGRATED rate function LAMBDA(t) to a homogeneous Poisson process via an inversion function, or (2), use a "thinning" method which acts as an acceptance-rejection sampling routine.
The method get_arrivals employs the former approach. The input allows the user to specify a piecewise linear approximation to their true arrival rate function. Returned is a list containing the arrival times governed by the arrival rate function.
EXAMPLE USAGE
# Specify the piecewise linear arrival rate via knots.
# Below we specify arrival_rate = 1 at time = 0, arrival_rate = 2 at time = 5,
# arrival_rate = 1 at time = 2.5 (linearity between time = 0 and time = 5), etc.
>>> knots = {0: 1, 5: 2, 12: 0.3, 15: 0.3, 16: 0, 18: 0, 20: 2}
>>> arrs = nhpp.get_arrivals()
# Print out our arrival times.
>>> for arr in arrs:
print(round(arr, 2))
0
0.08
1.1
1.14
2.35
2.41
2.45
2.91
3.67
4.41
4.65
4.7
6.78
7.13
7.18
8.12
10.15
18.33
19.21
19.53
19.54
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.