Markov processes: Lab 2

The Poisson process: three ways to simulate one, and a change in the rate of Victorian coal mine disasters found by maximum likelihood.

PythonNumPyMatplotlibJupyter 2026

The second MASC13 lab leaves discrete time behind. A Markov chain jumps on a clock; a Poisson process has no clock at all, only a rate, and the lab builds one three different ways before turning it on real data.

Written with Mariam Petrosian and Stefan Volnitchi.

Three ways to build the same process

The first is inverse transform sampling. If $U$ is uniform then $-\log(1-U)/\lambda$ is exponential, so a process can be grown one gap at a time. The second uses a different fact: given that $n$ events happened by time $t$, those $n$ events are uniform and independent on $[0,t]$. So draw $n \sim \mathrm{Po}(\lambda t)$, scatter $n$ uniform points, sort them. This one generalises immediately to the plane, where the intensity becomes points per unit area, and to a triangle by reflecting the points that fall on the wrong side of the diagonal, which wastes nothing, where rejecting them would throw away half.

The third is thinning, and it is the one that handles a rate that varies. Simulate at the highest rate the intensity ever reaches, then keep each point with probability $\lambda(x)/\lambda_{\sup}$. What survives is a Poisson process with intensity $\lambda(x)$, because thinning a Poisson count binomially leaves a Poisson count.

How much data a rate estimate needs

The estimator is just $\hat\lambda = n/t$, and its confidence interval has width $3.92\,\hat\lambda/\sqrt{n}$. Ten times the data should therefore narrow it by $\sqrt{10} \approx 3.16$, and the measured widths across $n = 10$ to $100{,}000$ shrink by factors of 3.16, 3.08 and 3.15. Running the whole experiment ten thousand times, the nominal 95 percent interval covered the true rate 95.18 percent of the time.

A change in Victorian coal mines

The real data is 153 coal mine disasters in the United Kingdom between 1851 and 1918. Fitting a single rate gives 2.30 disasters per year, and the fit is visibly wrong: the counting process runs well above the straight line early and flattens later.

Rather than pick a break by eye, the split is chosen by maximising the profile log-likelihood of a two-rate model over every possible split point. It lands on 1890, with 3.21 disasters per year before and 1.02 after. A confidence interval for the difference is $(1.51,\ 2.87)$, comfortably clear of zero, so the drop is not an artefact of where the break was placed.

The cumulative casualty process bends at the same time, which matters: a fall in the number of disasters could just mean fewer mines. The plausible causes are regulation, better technology and training, and the casualty curve also carries sharp vertical jumps, each one a single disaster that killed many people at once.

When the parameters are not equally knowable

The last section fits an intensity $\lambda(x) = \theta_1 + \theta_2\cos(2\pi x/S) + \theta_3\sin(2\pi x/S)$ by maximum likelihood, and the interesting result is that the three parameters are not equally easy to recover. $\theta_1$ is fixed by the total event count alone, since $\Lambda(S) = \theta_1 S$. The other two depend on where in the interval the events fell, not just how many there were, and the trigonometric terms are near their peaks for only part of the interval, so those estimators simply see less. Pushing $\theta_1$ down to about 5 is where the estimates fall apart, for the same reason: too few events to justify the normal approximation at all.

What this involved

Simulation by three methods, maximum likelihood by hand and numerically, profile likelihood for the change point, and confidence intervals whose coverage was checked by experiment rather than assumed.


Five realizations with $\lambda = 2$, each grown from exponential inter-arrival times. The dashed line is $E[N(t)] = \lambda t$.
Five realizations with $\lambda = 2$, each grown from exponential inter-arrival times. The dashed line is $E[N(t)] = \lambda t$.
Left: the counting process over 1851 to 1918, against a constant intensity of 2.30 disasters a year. Right: the gaps between disasters, with the exponential density that a constant rate would imply.
Left: the counting process over 1851 to 1918, against a constant intensity of 2.30 disasters a year. Right: the gaps between disasters, with the exponential density that a constant rate would imply.
The same process against years, beside the cumulative casualties. Both flatten around 1896; the casualty curve also has sharp jumps, each a single disaster that killed many.
The same process against years, beside the cumulative casualties. Both flatten around 1896; the casualty curve also has sharp jumps, each a single disaster that killed many.
The second construction: draw the count from a Poisson distribution, then scatter that many uniform points. Shown on $[0, 100]$ for four intensities.
The second construction: draw the count from a Poisson distribution, then scatter that many uniform points. Shown on $[0, 100]$ for four intensities.
The same method in the plane, where the intensity counts points per unit area.
The same method in the plane, where the intensity counts points per unit area.
On the triangle, by reflecting the points that land above $x + y = 1$. Rejecting them instead would throw away half the sample.
On the triangle, by reflecting the points that land above $x + y = 1$. Rejecting them instead would throw away half the sample.
A non-homogeneous process by thinning: simulate at the maximum rate 8, keep each point with probability $\lambda(x)/8$. Events cluster under the peaks and vanish at the zeros.
A non-homogeneous process by thinning: simulate at the maximum rate 8, keep each point with probability $\lambda(x)/8$. Events cluster under the peaks and vanish at the zeros.
Two realizations of the fitted intensity $\theta = [20, 15, 0]$. Different every run, the same shape every time: steep near the ends, flat around $t = 5$.
Two realizations of the fitted intensity $\theta = [20, 15, 0]$. Different every run, the same shape every time: steep near the ends, flat around $t = 5$.