The Poisson process: three ways to simulate one, and a change in the rate of Victorian coal mine disasters found by maximum likelihood.
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.
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.
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.
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.
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.
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.
Back to all engineering work, or the lecture notes.