Stochastic models and the state-space view
We want to find out two things:
We want to do this on the basis of observations (data), \(y\).
This kind of model is sometimes called a Bayesian hierarchical model.
Baguelin et al. (2013)

Applying the chain rule gives the joint probability
\[p(y, x, \theta) = p(y \mid x, \theta)\, p(x \mid \theta)\, p(\theta)\]
The joint probability
\[p(y, x, \theta) = p(y \mid x, \theta)\, p(x \mid \theta)\, p(\theta)\]
encodes everything about our model.
To do model fitting and inference, set \(y\) to the data we observe and calculate the posterior
\[p(x, \theta \mid y) = \frac{p(y, x, \theta)}{p(y)}\]
We can rewrite this as
\[p(x, \theta \mid y) = p(\theta \mid y)\, p(x \mid \theta, y)\]
\[p(x, \theta \mid y) = p(\theta \mid y)\, p(x \mid \theta, y)\]
In a deterministic model, every \(\theta\) leads to one possible \(x_{\theta}\). In that case
\[p(x_{\theta}, \theta \mid y) = p(\theta \mid y)\]
In general we cannot write down a formula for \(p(x_{\theta}, \theta, y)\). But we can sample from it.
The most remote inhabited island in the world: 284 people, one ship every few months.
An influenza-like illness arrived with a visiting ship and infected most of the island over eight weeks.
Two features make it the standard teaching example:
That second wave is the whole problem. A simple SIR model cannot produce it.
T is temporary immunity, and only a fraction \(\alpha\) goes on to L, long-term immunity. The rest return to susceptible — and can drive a second wave.
Model structure — how many compartments, and what flows between them.
Deterministic or stochastic — whether transitions are continuous flows or discrete random events.
These are separate decisions. You can simulate SEITL either way, and the practical does both so you can see the difference.
With 284 people, chance is not a rounding error.
Demographic noise scales roughly as \(1/\sqrt{N}\). On an island of 284 it is a first-order effect, and it is why the rest of the course needs heavier machinery.
The deterministic version solves an ODE. The stochastic version simulates events one at a time.
Exact, and slow. Every infection and recovery is an individual event.
A single T compartment means the waiting time in it is exponential, so the most likely thing is to leave immediately.
That is a strange claim about immunity.
Chaining four compartments, each at four times the rate, gives an Erlang waiting time: same mean, but a peak away from zero. Most people stay immune for roughly the average duration.

In the practical you will
Putting it all together