← Stochastic Differential Equations

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

EventChange 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

\[ dS=-a_1dt-\sqrt{a_1}dW_1, \] \[ dE=(a_1-a_2)dt+\sqrt{a_1}dW_1-\sqrt{a_2}dW_2, \] \[ dI=(a_2-a_3)dt+\sqrt{a_2}dW_2-\sqrt{a_3}dW_3, \] \[ dR=a_3dt+\sqrt{a_3}dW_3. \]

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

Interactive PythonStochastic SEIR construction

Output

Run the code to see the result.

Understand the matrix code

ExpressionMeaning
V @ ratesAdds the mean effect of all event channels to each compartment.
np.sqrt(rates) * dWCreates 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

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.