08
Constructing a stochastic SEIR model
The stochastic SEIR model adds a latent progression channel and shows how event-vector programming scales cleanly to more compartments.
Three biological events
| Event | Change in \((S,E,I,R)\) | Rate |
|---|---|---|
| Infection | \((-1,+1,0,0)\) | \(a_1=\beta SI/N\) |
| Progression | \((0,-1,+1,0)\) | \(a_2=\sigma E\) |
| Recovery | \((0,0,-1,+1)\) | \(a_3=\gamma I\) |
Four coupled SDEs
The three Brownian motions are independent event-channel noises. Within a channel, the same increment is used with opposite signs in the source and destination compartments.
What the exposed stage changes
Infection adds to \(E\), not directly to \(I\). Progression transfers exposed people to infectiousness after a random latent period. Thus infection noise first affects \(S,E\), while progression noise links \(E,I\).
Interactive Python laboratory
Output
Run the code to see the result.
Understand the matrix code
| Expression | Meaning |
|---|---|
V @ rates | Adds the mean effect of all event channels to each compartment. |
np.sqrt(rates) * dW | Creates one diffusion contribution per event. |
V @ (...) | Distributes each event’s random contribution with the correct signs. |
Population conservation
Every column of \(V\) sums to zero. Therefore both \(Va(X)dt\) and \(V\sqrt{\operatorname{diag}(a(X))}dW\) sum to zero. This is the structural reason the uncorrected SDE conserves \(S+E+I+R=N\).
Interpretation and conditions
- The mean latent period is \(1/\sigma\), but the diffusion does not impose a fixed delay.
- Extinction requires both \(E=0\) and \(I=0\).
- Continuous states approximate counts and are most credible away from small-count boundaries.
- The declared projection is a numerical safeguard, not part of the derived SDE.
What this lesson adds
You can now construct an SEIR diffusion with three event channels, use a state-change matrix, preserve population structurally, and explain how latent progression separates infection from infectiousness.