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
| Event | Change 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
Therefore
Construct the diffusion variance
For independent event counts, variances add after multiplying by the squared state changes:
The recovery sign disappears after squaring. Recoveries reduce the drift but still increase uncertainty.
The stochastic SIS model
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.
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
| CTMC | SDE approximation |
|---|---|
| Integer state and individual jumps | Continuous state and continuous path |
| Exact extinction event at \(I=0\) | Boundary behaviour depends on model and numerical treatment |
| Best for small counts and event detail | Often 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.