Module contents
Lesson 6 of 31Core 100 min

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 λ\lambda implies mean waiting time 1/λ1/\lambda 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.

InteractiveThe interval encountered by a passenger
  • Between buses
  • Interval containing the passenger
  • Passenger arrival and wait
Means over 2000 replicates
Typical intervalSample 1.02 min · theory 1.00 min
Observed intervalSample 2.02 min · theory 2.00 min
Remaining waitSample 1.04 min · theory 1.00 min

Each bar is a simulated mean; the thin mark indicates its theoretical value. The model is a stationary renewal process with Erlang intervals of mean μ and shape k. An independent time falls more often in long intervals: the observed interval has mean μ(1 + 1/k), and remaining wait half of that. With k = 1 arrivals are Poisson; as k grows, intervals become more regular.

The example’s typical and observed intervals are independent draws from their respective distributions; the passenger is uniformly placed within the observed interval. This does not simulate a single bus line with real passengers.

1
1.0
1
Example typical interval0.90 min
Example observed interval3.42 min
Example remaining wait1.00 min
Coefficient of variation between buses1.000
Seed2606
Compare typical intervals with intervals observed at a random time in stationarity. Change waiting-time variability; the complete interval and residual wait have different means.

Three ways to construct the process

The increments are also stationary: their law depends only on duration. For 0<s<t0<s<t, the values NsN_s and NtN_t are not independent: NsN_s is contained in NtN_t and their covariance is λs>0\lambda s>0. On s=0s=0 the count is constant. In NumPy’s parameterization, exponential(scale=1/lambda_) takes the mean, not the rate.

A second construction takes independent waits Ei∼Exp⁡(λ)E_i\sim\operatorname{Exp}(\lambda), defines Tn=E1+⋯+EnT_n=E_1+\cdots+E_n and counts Nt=max⁡{n:Tn≤t}N_t=\max\{n:T_n\le t\}. Prove equivalence. For the Poisson-increment process, P(T1>t)=P(Nt=0)=e−λt\Pr(T_1>t)=\Pr(N_t=0)=e^{-\lambda t}. More generally, for 0<t1<⋯<tk0<t_1<\cdots<t_k, independent increments on deterministic intervals give joint density λke−λtk\lambda^ke^{-\lambda t_k} for the first kk arrivals: require one arrival in each chosen infinitesimal interval and none between them. Changing to waits wi=ti−ti−1w_i=t_i-t_{i-1} with unit Jacobian factors that density as ∏iλe−λwi\prod_i\lambda e^{-\lambda w_i}; they are independent exponentials. Conversely, TnT_n has gamma density λntn−1e−λt/(n−1)!\lambda^nt^{n-1}e^{-\lambda t}/(n-1)!. Since {Nt=n}={Tn≤t<Tn+1}\{N_t=n\}=\{T_n\le t<T_{n+1}\}, integrating the density of TnT_n against the probability of no further arrival before tt gives e−λt(λt)n/n!e^{-\lambda t}(\lambda t)^n/n!. 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 [0,T][0,T] with nn independent cells having probability p=λT/np=\lambda T/n of containing an arrival, provided n≥λTn\ge\lambda T. The count is binomial, not exactly Poisson for finite nn. For n→∞n\to\infty, (nk)(λT/n)k(1−λT/n)n−k→e−λT(λT)k/k!\binom nk(\lambda T/n)^k(1-\lambda T/n)^{n-k}\to e^{-\lambda T}(\lambda T)^k/k! for each kk; the same factorization over disjoint intervals gives the Poisson limit’s finite-dimensional laws.

InteractiveFrom rare events to Poisson

Divide an interval of length T into n independent cells and allow at most one event per cell, with probability λT/n. The total count is binomial; the reference comparison is Poisson with the same mean λT. Distribution points are discrete and lines only connect them.

  • Binomial count
  • Poisson with mean λT

The plot is limited to a window around the mean; TV distance sums every value from 0 to n and adds Poisson mass above n. It is computed by recurrences, subject to numerical rounding.

  • Geometric wait on the grid
  • Exponential wait

To study a gap, extend the grid with independent cells of the same probability. If G counts cells until the first event, the wait is GT/n and its survival at u=t/T is (1−λT/n) raised to ⌊nu⌋. The exponential reference has survival exp(−λTu). As n grows with fixed λT, the steps converge to the curve; n=λT gives probability one per cell and is shown without division by zero.

4
16
Probability per cell25.00 %
TV distance of counts0.072109
Poisson tail above n0.000001
Increase the number of cells and compare the binomial count with the Poisson law, including the tail exceeding n. Rescaled geometric gaps are compared with exponential waits in the limit.

Combine, mark and condition arrivals

Superposition and thinning are complementary operations. If N(1)N^{(1)} and N(2)N^{(2)} are independent Poisson processes with rates λ1,λ2\lambda_1,\lambda_2, their sum is Poisson with rate λ1+λ2\lambda_1+\lambda_2: the generating functions of their increments multiply and disjoint increments remain independent. If each arrival of a Poisson process with rate λ\lambda is independently marked with probability pp, accepted and rejected counts are independent Poisson processes with rates pλp\lambda and (1−p)λ(1-p)\lambda.

To justify independence of the two counts on an interval, condition on the original count and use the joint generating function:

E[uNAvNR]=exp⁡{λt[p(u−1)+(1−p)(v−1)]}.\E[u^{N_A}v^{N_R}]=\exp\{\lambda t[p(u-1)+(1-p)(v-1)]\}.

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 λ1+λ2\lambda_1+\lambda_2 and belongs to process 1 with probability λ1/(λ1+λ2)\lambda_1/(\lambda_1+\lambda_2), for positive sum of rates.

The order-statistics property says that, conditional on NT=nN_T=n, ordered arrival times have the same law as nn independent uniforms on [0,T][0,T] in sorted order. For 0<t1<⋯<tn<T0<t_1<\cdots<t_n<T, the joint density of those arrivals and none additional up to TT is λne−λT\lambda^ne^{-\lambda T}. Dividing by P(NT=n)=e−λT(λT)n/n!\Pr(N_T=n)=e^{-\lambda T}(\lambda T)^n/n! gives constant density n!/Tnn!/T^n on the ordered simplex. Therefore the count inside [0,s][0,s], given total nn, is binomial (n,s/T)(n,s/T).

For positive iid intervals LL with mean μ\mu and finite second moment, observed in stationary renewal, an independent time falls in a size-biased interval: E[Lobservado]=E[L2]/μ\E[L_{\mathrm{observado}}]=\E[L^2]/\mu. The mean residual wait is E[L2]/(2μ)\E[L^2]/(2\mu) because, conditional on the interval, the time’s position is uniform. If gaps are exponential with mean μ\mu, these means are 2μ2\mu and μ\mu. If deterministic, they are μ\mu and μ/2\mu/2. This comparison requires stationarity; a window starting at the first arrival has boundary effects.

Finally, relative to the homogeneous process’s natural filtration, Nt−λtN_t-\lambda t is a martingale: the expectation of the future increment, independent of history, is λ(t−s)\lambda(t-s). 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 λ(t)\lambda(t) has independent increments and Nt−Ns∼Poisson⁡(Λ(t)−Λ(s))N_t-N_s\sim\operatorname{Poisson}(\Lambda(t)-\Lambda(s)), where Λ(t)=∫0tλ(u)  ⁣du\Lambda(t)=\int_0^t\lambda(u)\,\dd u. If Λ\Lambda increases strictly without bound, Nt=N~Λ(t)N_t=\widetilde N_{\Lambda(t)} for a unit-rate Poisson process N~\widetilde N. In general use a generalized inverse and separately treat zero-intensity intervals or a clock with finite total mass.

For observed times 0<t1<⋯<tn<T0<t_1<\cdots<t_n<T, the log-likelihood, apart from a constant independent of θ\theta, is

ℓ(θ)=∑i=1nlog⁡λθ(ti)−∫0Tλθ(t)  ⁣dt.\ell(\theta)=\sum_{i=1}^n\log\lambda_\theta(t_i)-\int_0^T\lambda_\theta(t)\,\dd t.

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 0≤λ(t)≤λˉ0\le\lambda(t)\le\bar\lambda on [0,T][0,T]: generate homogeneous Poisson candidates at rate λˉ\bar\lambda and accept each candidate tt with probability λ(t)/λˉ\lambda(t)/\bar\lambda using independent uniform marks. For disjoint intervals, marks preserve independence; on each interval the generating function gives a Poisson count with mean ∫λ\int\lambda. This applies the marking theorem and is documented in the original paper.

InteractiveThin candidates
  • Intensity
  • Accepted
  • Rejected

Points are candidates from the first replicate, with height uniform between 0 and 5. Each point whose mark is below the curve is accepted. The bound always dominates intensity, including between controls, because interpolation is linear.

  • Histogram of 300 replicates
  • Theoretical intensity

Each bar divides the count accepted in its interval by 300 and the interval width, here equal to 1. Its expectation is the mean intensity in that interval; the curve shows pointwise intensity. Differences are simulation fluctuations.

1.5
3.5
2.0
4.0
1.0
2.5
1
Candidates in first replicate49
Accepted in first replicate25
Rejected in first replicate24
Accepted fraction in that replicate51.0 %
Expected acceptance fraction50.0 %
Mean accepted per replicate25.32
Theoretical mean count25.00
Adjust intensity and compare candidates with accepted arrivals. Marks are reused when changing the curve to observe the intensity's effect on the same realization.

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 St=∑i=1NtYiS_t=\sum_{i=1}^{N_t}Y_i sums iid marks independent of the count. If EY2<∞\E Y^2<\infty, conditioning on NtN_t gives

ESt=λt EY,Var⁡(St)=λt E[Y2].\E S_t=\lambda t\,\E Y,\qquad \Var(S_t)=\lambda t\,\E[Y^2].

The second formula includes variability in the number of terms: it is λt(Var⁡Y+(EY)2)\lambda t(\Var Y+(\E Y)^2), not just λtVar⁡Y\lambda t\Var Y. For nonnegative marks and s≥0s\ge0, the Laplace transform is E[e−sSt]=exp⁡{λt(Ee−sY−1)}\E[e^{-sS_t}]=\exp\{\lambda t(\E e^{-sY}-1)\}. When λt\lambda t is large and the second moment finite, a centered and scaled normal approximation can be useful, but the total retains mass e−λte^{-\lambda t} 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.

[ ]Homogeneous arrivals and thinningBrowser
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 λ(t)=a+bt\lambda(t)=a+bt, a>0a>0, b>0b>0, the inverse clock has closed form: if u=at+bt2/2u=at+bt^2/2, then t=2u/(a+a2+2bu)t=2u/(a+\sqrt{a^2+2bu}). 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.

[ ]Inversion and thinning for a linear rateBrowser
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:

λθ(t)=exp⁡[θ0+θ1t/T+θ2sin⁡(2πt/24)+θ3cos⁡(2πt/24)].\lambda_\theta(t)=\exp\left[\theta_0+\theta_1t/T+\theta_2\sin(2\pi t/24)+\theta_3\cos(2\pi t/24)\right].

On [0,T][0,T], a valid bound is exp⁡(θ0+max⁡(0,θ1)+θ22+θ32)\exp(\theta_0+\max(0,\theta_1)+\sqrt{\theta_2^2+\theta_3^2}). Fit the likelihood with numerical quadrature and show both parameters and mean intensity; one realization of arrivals does not recover true parameters exactly.

[ ]Maximum likelihood for synthetic arrivalsBrowser
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 TT 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.

[ ]Independent validation in compensated timeBrowser
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 N∼Poisson⁡(12)N\sim\operatorname{Poisson}(12) claims arrive and their amounts are exponential with mean 5000, the total’s mean is 6000060000 and its variance is 600000000600000000, because EY2=2⋅50002\E Y^2=2\cdot5000^2. The code first generates the number of claims in each replication and then all individual marks, grouping them by replication.

[ ]Compound Poisson from individual marksBrowser
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 λ(x,y)=0.4+0.6x\lambda(x,y)=0.4+0.6x. 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 0.2750.275 and 0.4250.425.

[ ]Spatial Poisson by markingBrowser
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

NumericArrivals in half a minute
In a process with rate 3 per minute, exactly 4 arrivals were observed in one minute. What is the probability that at least 2 were in the first 30 seconds?
NumericExpected losses
Claims arrive at rate 12 per year and their exponential mean amount is 5000. What is the expected total loss in one year?
NumericVariance of losses
With rate 12 claims per year and exponential mean amount 5000, calculate the annual total variance.
QuizSuperpose, mark and race
Two independent Poisson processes have positive rates λ₁ and λ₂. Which statements are correct?

More than one answer may be correct.

ProofTimes conditional on the total
Prove: Prove that the times of n arrivals of a homogeneous Poisson process on [0,T], conditional on N_T=n, are the order statistics of n independent uniforms.
0
Work on the region 0<t₁<⋯<tₙ<T.

Step 1 of 3. What is the joint density of the n arrivals and no additional arrival before T?

CodeSimulate a bounded intensity
Implement 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):
  pass
Shift+Enter to run
Key idea

The 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.