← Stochastic Differential Equations

06

Constructing a stochastic SIS model

A stochastic SIS SDE is not created by adding arbitrary noise. Its drift and diffusion are derived from the infection and recovery events of the underlying epidemic process.

Scenario and state

A closed SIS population contains \(N\) people. The state is the infectious count \(I(t)\), and \(S(t)=N-I(t)\). Recovery returns a person immediately to susceptibility.

Begin with biological events

EventChange in \(I\)Rate
Infection+1\(a_1(I)=\beta(N-I)I/N\)
Recovery−1\(a_2(I)=\gamma I\)

The SDE approximation must retain both the average net effect and the variability generated by these two event streams.

Construct the drift

\[f(I)=(+1)a_1(I)+(-1)a_2(I)=a_1(I)-a_2(I).\]

Therefore

\[f(I)=\beta\frac{(N-I)I}{N}-\gamma I.\]

Construct the diffusion variance

For independent event counts, variances add after multiplying by the squared state changes:

\[g^2(I)=(+1)^2a_1(I)+(-1)^2a_2(I)=a_1(I)+a_2(I).\]
\[g(I)=\sqrt{\beta\frac{(N-I)I}{N}+\gamma I}.\]

The recovery sign disappears after squaring. Recoveries reduce the drift but still increase uncertainty.

The stochastic SIS model

\[ dI=\left[\beta\frac{(N-I)I}{N}-\gamma I\right]dt +\sqrt{\beta\frac{(N-I)I}{N}+\gamma I}\,dW. \]

At \(I=0\), both coefficients vanish, matching the disease-free absorbing state. The SDE is a continuous approximation: \(I\) need not remain integer.

Interactive Python laboratory

Run one Euler–Maruyama SIS path beside its deterministic solution. A second graph shows how drift direction and diffusion strength change across the state space.

Interactive PythonStochastic SIS model

Output

Run the code to see the result.

Why max(total_event_rate, 0) appears

Mathematically, the total rate is non-negative on \(0\le I\le N\). Tiny floating-point errors or an invalid numerical state could otherwise make a square root fail. This guard does not make an invalid biological model valid; the state and parameter checks remain necessary.

The boundary projection is a declared numerical choice

np.clip(proposed_I, 0, N) projects an Euler–Maruyama proposal back into the biological interval. It is simple, but it changes the raw numerical scheme. The program reports how often it was used. Later lessons compare boundary treatments and time-step effects rather than hiding them.

SDE versus CTMC SIS

CTMCSDE approximation
Integer state and individual jumpsContinuous state and continuous path
Exact extinction event at \(I=0\)Boundary behaviour depends on model and numerical treatment
Best for small counts and event detailOften efficient for larger populations and approximate fluctuations

What this lesson adds

You can now derive a one-dimensional stochastic SIS model from its infection and recovery events, explain why rates subtract in drift but add in diffusion variance, program the state-dependent coefficients, and state the limitations of boundary projection.