Poisson processes and point processes
The Poisson process is the canonical model of randomly arriving events: server requests, transactions and alerts. Prove the equivalence of independent-increment and exponential-wait constructions and the rare-Bernoulli limit, study superposition, thinning and order statistics, and generalize to time-varying intensities and compound sums, with exact simulation by thinning.
After this lesson you can
- Prove equivalence between the independent-increment and exponential-wait definitions.
- Solve problems using superposition, thinning and order statistics, including the inspection paradox.
- Simulate nonhomogeneous processes by clock inversion and thinning, and verify their law.
- Estimate a nonhomogeneous intensity by maximum likelihood from arrival times.
- Calculate the mean, variance and approximate law of a compound Poisson process and simulate it.
Before you start
Arrivals without a shared clock
An API receives requests, a machine records failures and an insurer accumulates claims. Before predicting the next event, decide what a rate means: it is not a waiting time but an expected number of arrivals per unit time. A constant rate implies mean waiting time in the Poisson model.
Not all intervals are observed in the same way. A passenger arriving at an independent time is more likely to fall in a long interval than a short one. The figure distinguishes the whole interval containing the passenger from the remaining wait: these are different questions.
Three ways to construct the process
The increments are also stationary: their law depends only on duration. For , the values and are not independent: is contained in and their covariance is . On the count is constant. In NumPy’s parameterization, exponential(scale=1/lambda_) takes the mean, not the rate.
A second construction takes independent waits , defines and counts . Prove equivalence. For the Poisson-increment process, . More generally, for , independent increments on deterministic intervals give joint density for the first arrivals: require one arrival in each chosen infinitesimal interval and none between them. Changing to waits with unit Jacobian factors that density as ; they are independent exponentials. Conversely, has gamma density . Since , integrating the density of against the probability of no further arrival before gives . Exponential memorylessness implies that from a deterministic time the remaining wait is exponential and independent of past counts; iterating gives independent increments on disjoint intervals. A detailed proof in both directions appears in the MIT notes.
A third route approximates the process on with independent cells having probability of containing an arrival, provided . The count is binomial, not exactly Poisson for finite . For , for each ; the same factorization over disjoint intervals gives the Poisson limit’s finite-dimensional laws.
Combine, mark and condition arrivals
Superposition and thinning are complementary operations. If and are independent Poisson processes with rates , their sum is Poisson with rate : the generating functions of their increments multiply and disjoint increments remain independent. If each arrival of a Poisson process with rate is independently marked with probability , accepted and rejected counts are independent Poisson processes with rates and .
To justify independence of the two counts on an interval, condition on the original count and use the joint generating function:
The expression factors into two Poisson generating functions. Marks must be independent; a history-dependent rule does not automatically satisfy this conclusion. In a race between independent exponential waits, the first has rate and belongs to process 1 with probability , for positive sum of rates.
The order-statistics property says that, conditional on , ordered arrival times have the same law as independent uniforms on in sorted order. For , the joint density of those arrivals and none additional up to is . Dividing by gives constant density on the ordered simplex. Therefore the count inside , given total , is binomial .
For positive iid intervals with mean and finite second moment, observed in stationary renewal, an independent time falls in a size-biased interval: . The mean residual wait is because, conditional on the interval, the time’s position is uniform. If gaps are exponential with mean , these means are and . If deterministic, they are and . This comparison requires stationarity; a window starting at the first arrival has boundary effects.
Finally, relative to the homogeneous process’s natural filtration, is a martingale: the expectation of the future increment, independent of history, is . Enlarging the filtration must preserve that independence; revealing future arrivals invalidates the argument.
Change the clock and estimate a rate
A nonhomogeneous Poisson process with deterministic nonnegative locally integrable intensity has independent increments and , where . If increases strictly without bound, for a unit-rate Poisson process . In general use a generalized inverse and separately treat zero-intensity intervals or a clock with finite total mass.
For observed times , the log-likelihood, apart from a constant independent of , is
The first part rewards high rates at arrivals; the integral penalizes predicting many arrivals that did not occur. A log-linear rate can include trend and seasonality, but estimating its parameters and then testing the same times as though parameters were known yields a miscalibrated diagnostic. Reserve independent observations to examine the fitted clock.
Thinning and aggregate losses
The Lewis-Shedler method exactly simulates a process with on : generate homogeneous Poisson candidates at rate and accept each candidate with probability using independent uniform marks. For disjoint intervals, marks preserve independence; on each interval the generating function gives a Poisson count with mean . This applies the marking theorem and is documented in the original paper.
The bound must dominate intensity over the entire domain. Checking it only at observed candidates does not certify this. The same principle constructs a spatial Poisson process: in a bounded region generate candidates with dominating constant intensity per unit area and mark each point according to local spatial intensity.
A compound Poisson process sums iid marks independent of the count. If , conditioning on gives
The second formula includes variability in the number of terms: it is , not just . For nonnegative marks and , the Laplace transform is . When is large and the second moment finite, a centered and scaled normal approximation can be useful, but the total retains mass at zero if marks are positive: the normal is not its exact law.
Lab: simulation with two clocks
First build simulators with NumPy. The thinning function checks the rate at every candidate, but this does not prove the bound dominates the function between candidates: the caller must separately establish a global bound. The generator takes scale=1/rate_max, the exponential mean. Arrivals are naturally ordered by accumulating times.
import numpy as np
def poisson_homogeneo(tasa, T, rng):
if not np.isfinite(tasa) or not np.isfinite(T) or tasa <= 0 or T < 0:
raise ValueError('tasa positiva y horizonte no negativo')
puntos, t = [], 0.
while True:
t += rng.exponential(1/tasa)
if t > T:
return np.array(puntos)
puntos.append(t)
def simulate_nhpp(rate_fn, rate_max, T, rng):
if not np.isfinite(rate_max) or not np.isfinite(T) or rate_max <= 0 or T < 0:
raise ValueError('cota positiva y horizonte no negativo')
candidatos = poisson_homogeneo(rate_max, T, rng)
aceptados = []
for t in candidatos:
tasa = float(rate_fn(t))
if not np.isfinite(tasa) or tasa < 0 or tasa > rate_max:
raise ValueError('la tasa evaluada está fuera de la cota')
if rng.random() * rate_max < tasa:
aceptados.append(t)
return np.array(aceptados)For an example with , , , the inverse clock has closed form: if , then . This form avoids cancellation from subtracting two nearby numbers. Compare arrival counts from inversion and thinning with theoretical mean and variance; these are independent simulations and their values fluctuate.
def lineal_inversion(a, b, T, rng):
reloj = poisson_homogeneo(1, a*T + b*T*T/2, rng)
return 2*reloj/(a + np.sqrt(a*a+2*b*reloj))
rng = np.random.default_rng(26061)
a, b, T, replicas = 0.5, 0.2, 10., 2000
inversion = np.array([len(lineal_inversion(a, b, T, rng)) for _ in range(replicas)])
adelgazado = np.array([len(simulate_nhpp(lambda t: a+b*t, a+b*T, T, rng)) for _ in range(replicas)])
media_teorica = a*T+b*T*T/2
print('conteo teórico, media y varianza:', media_teorica)
print('inversión, media y varianza:', round(inversion.mean(), 4), round(inversion.var(ddof=1), 4))
print('adelgazamiento, media y varianza:', round(adelgazado.mean(), 4), round(adelgazado.var(ddof=1), 4))Fit an intensity and check its clock
Construct synthetic request data with trend and daily cycle:
On , a valid bound is . Fit the likelihood with numerical quadrature and show both parameters and mean intensity; one realization of arrivals does not recover true parameters exactly.
from scipy.optimize import minimize
from scipy.integrate import cumulative_trapezoid
T = 240.
verdadero = np.array([0.35, 0.25, 0.45, -0.2])
def diseno(t):
t = np.asarray(t)
return np.stack((np.ones_like(t), t/T, np.sin(2*np.pi*t/24), np.cos(2*np.pi*t/24)), axis=-1)
def intensidad(t, theta):
return np.exp(diseno(t) @ theta)
def cota(theta):
return np.exp(theta[0] + max(0., theta[1]) + np.hypot(theta[2], theta[3]))
rng = np.random.default_rng(26062)
llegadas = simulate_nhpp(lambda t: intensidad(t, verdadero), cota(verdadero), T, rng)
malla = np.linspace(0, T, 2401)
D = diseno(malla)
Dt = diseno(llegadas)
def negativo(theta):
tasa = np.exp(D @ theta)
integral = np.trapezoid(tasa, malla)
gradiente = np.trapezoid(tasa[:, None] * D, malla, axis=0) - Dt.sum(axis=0)
return integral - np.sum(Dt @ theta), gradiente
ajuste = minimize(negativo, np.array([0., 0., 0., 0.]), jac=True, method='BFGS')
if not ajuste.success and np.linalg.norm(ajuste.jac) > 1e-4:
raise RuntimeError('el ajuste no ha convergido: ' + ajuste.message)
estimado = ajuste.x
print('llegadas de entrenamiento:', len(llegadas))
print('parámetros verdaderos:', verdadero)
print('parámetros estimados:', np.round(estimado, 4))
print('tasa media verdadera / ajustada:', round(np.trapezoid(intensidad(malla, verdadero), malla)/T, 5),
round(np.trapezoid(intensidad(malla, estimado), malla)/T, 5))Now generate independent validation data, repeating the true intensity every hours. Also retain intervals crossing boundaries between windows. Collect a fixed number of interarrival times in compensated time: this does not turn the last interval censored by a fixed horizon into a complete observation. The exact and fitted clocks are integrated on the same grid; their interpolated values are numerical approximations.
from scipy.stats import kstest
def reloj_malla(theta):
return np.concatenate(([0.], cumulative_trapezoid(intensidad(malla, theta), malla)))
L_true, L_hat = reloj_malla(verdadero), reloj_malla(estimado)
rng = np.random.default_rng(26063)
u_true, u_hat = [], []
ventana = 0
while len(u_true) < 301:
puntos = simulate_nhpp(lambda t: intensidad(t, verdadero), cota(verdadero), T, rng)
u_true.extend(ventana*L_true[-1] + np.interp(puntos, malla, L_true))
u_hat.extend(ventana*L_hat[-1] + np.interp(puntos, malla, L_hat))
ventana += 1
esperas_true = np.diff(np.r_[0., u_true[:300]])
esperas_hat = np.diff(np.r_[0., u_hat[:300]])
print('medias de las esperas, reloj verdadero / ajustado:', round(esperas_true.mean(), 4), round(esperas_hat.mean(), 4))
print('KS contra exponencial unitaria, verdadero:', np.round(kstest(esperas_true, 'expon')[:2], 4))
print('KS contra exponencial unitaria, ajustado:', np.round(kstest(esperas_hat, 'expon')[:2], 4))The test with the true clock and fixed number of waits checks the generator and quadrature. The KS value with the estimated clock is a diagnostic, not an exact goodness-of-fit p-value: the fit is uncertain even with independent validation data. An independent window may contain zero arrivals; the clock offset per window handles that case too.
Lab: claims and a random sum
In one year, if claims arrive and their amounts are exponential with mean 5000, the total’s mean is and its variance is , because . The code first generates the number of claims in each replication and then all individual marks, grouping them by replication.
rng = np.random.default_rng(26064)
M = 30_000
conteos = rng.poisson(12, M).astype(np.int32)
propietario = np.repeat(np.arange(M, dtype=np.int32), conteos).astype(np.int32)
marcas = rng.exponential(5000, len(propietario))
perdidas = np.bincount(propietario, weights=marcas, minlength=M)
print('media empírica y exacta:', round(perdidas.mean(), 2), 12*5000)
print('varianza empírica y exacta:', round(perdidas.var(ddof=1), 2), 12*2*5000**2)
print('proporción de años sin siniestro:', round(np.mean(conteos == 0), 6), 'teórica:', round(np.exp(-12), 6))The fraction of claim-free years has substantial uncertainty at this rate: the exact mass is small and the sample may contain none. The experiment does not prove validity of a normal approximation in loss tails.
To see the spatial construction, take the unit square with intensity per unit area . The maximum is one. Generate candidates with Poisson count of mean one, place them uniformly in the square and accept them with that intensity. By integration, theoretical mean counts in the left and right halves are and .
rng = np.random.default_rng(26065)
izquierda, derecha = [], []
for _ in range(5000):
candidatos = rng.random((rng.poisson(1), 2))
puntos = candidatos[rng.random(len(candidatos)) < 0.4 + 0.6*candidatos[:, 0]]
izquierda.append(np.sum(puntos[:, 0] < .5))
derecha.append(np.sum(puntos[:, 0] >= .5))
print('medias izquierda y derecha:', round(np.mean(izquierda), 4), round(np.mean(derecha), 4))
print('medias teóricas:', 0.275, 0.425)Exercises
More than one answer may be correct.
Step 1 of 3. What is the joint density of the n arrivals and no additional arrival before T?
simulate_nhpp(rate_fn, rate_max, T, rng) by thinning. rate_max is a positive global bound supplied by the caller, T is nonnegative, and rng is a NumPy generator. Return a sorted array of arrivals and reject evaluated rates outside [0, rate_max].import numpy as np
def simulate_nhpp(rate_fn, rate_max, T, rng):
passThe homogeneous Poisson process connects independent increments with exponential waits. Marking and superposition preserve the structure under independence assumptions; conditioning on the total produces ordered uniform times. Time change and thinning construct variable intensities, and compound sums incorporate variation in both marks and counts.