← Stochastic Differential Equations

Deterministic vs CTMC vs SDE models

Deterministic ODEs, continuous-time Markov chains and stochastic differential equations can describe the same biological mechanisms at different mathematical resolutions. The important difference is not simply that one is “random” and another is not. They represent biological change in fundamentally different ways.

Core idea. An ODE describes systematic population-level change, a CTMC describes random discrete events, and an SDE describes continuous random fluctuations around systematic change.

Start with one biological mechanism

Consider an SIS epidemic in a population of size \(N\). Let \(I(t)\) be the number of infectious individuals and \(S(t)=N-I(t)\).

Two biological events occur:

EventState changeRate
infection\(I\to I+1\)\(\beta (N-I)I/N\)
recovery\(I\to I-1\)\(\gamma I\)

The three modelling approaches can now be built from exactly these same mechanisms.

Deterministic model: keep the net average tendency

The infection rate increases \(I\), while the recovery rate decreases it. Their difference gives the deterministic rate of change:

\[\boxed{\frac{dI}{dt}=\beta\frac{(N-I)I}{N}-\gamma I}.\]

For fixed parameters and initial condition, this equation produces one smooth trajectory.

Interpretation. The deterministic model says how the infectious population changes at the population level according to the net infection–recovery tendency. It does not represent which individual event happens next.

What information has been removed?

Suppose infection and recovery rates are both substantial. The deterministic equation uses their difference. It therefore describes net change but does not retain the randomness of the two event streams.

Two epidemics with identical parameters can experience different sequences of infection and recovery events. The deterministic model does not distinguish those possible histories.

CTMC model: keep the individual random events

In a continuous-time Markov chain, \(I(t)\) remains integer-valued:

\[0,1,2,\ldots,N.\]

When the current state is \(I=i\), infection occurs at rate

\[b(i)=\beta\frac{(N-i)i}{N},\]

and recovery occurs at rate

\[d(i)=\gamma i.\]

The total event rate is

\[\lambda(i)=b(i)+d(i).\]

The waiting time until the next event is exponentially distributed:

\[T\sim\operatorname{Exp}(\lambda(i)).\]

Conditional on an event occurring,

\[P(\text{infection})=\frac{b(i)}{b(i)+d(i)},\qquad P(\text{recovery})=\frac{d(i)}{b(i)+d(i)}.\]
Interpretation. The CTMC asks: when will the next event happen, and will that event be an infection or a recovery?

Why CTMC trajectories have steps

Between events, the state does not change. An infection then changes \(I\) by exactly \(+1\), or a recovery changes it by exactly \(-1\). This produces a step-like trajectory.

Because \(I=0\) can be an absorbing state in an SIS epidemic without importation, exact extinction occurs naturally in the CTMC.

SDE model: approximate many random events continuously

For a birth–death-type process, the expected short-time change is approximately

\[E[\Delta I\mid I=i]\approx[b(i)-d(i)]\Delta t,\]

while its variance is approximately

\[\operatorname{Var}(\Delta I\mid I=i)\approx[b(i)+d(i)]\Delta t.\]

This motivates the diffusion approximation

\[\boxed{dI_t=[b(I_t)-d(I_t)]dt+\sqrt{b(I_t)+d(I_t)}\,dW_t}.\]

For the SIS model,

\[\boxed{dI_t=\left[\beta\frac{(N-I_t)I_t}{N}-\gamma I_t\right]dt+\sqrt{\beta\frac{(N-I_t)I_t}{N}+\gamma I_t}\,dW_t}.\]

Why difference in the drift but sum in the diffusion?

Infections move the state upward and recoveries move it downward, so their signed contributions subtract in the mean:

\[b-d.\]

But both event types create variability. Since the squared size of either a \(+1\) or \(-1\) event is 1, their variance contributions add:

\[b+d.\]
This connects all three models. The deterministic model keeps \(b-d\). The CTMC keeps the separate random event rates \(b\) and \(d\). The SDE keeps \(b-d\) as drift and approximates event variability through \(\sqrt{b+d}\).

The three trajectory types

Illustrative trajectories generated from the same SIS infection and recovery mechanisms. The deterministic model is smooth, the CTMC is integer-valued and step-like, and the SDE is continuous but irregular. The panels use the same time and infectious-population scales to make the structural differences visible.

Do stochastic models just give the same answer with wiggles?

No. The purpose of stochastic modelling is not merely to make a deterministic curve look irregular.

A stochastic model defines a probability distribution over possible histories. Repeating the model can therefore answer questions that one deterministic trajectory cannot:

QuestionWhy stochastic modelling helps
Could an early outbreak die out?different event sequences can lead to extinction or growth
How uncertain is the epidemic peak?different trajectories have different peak sizes and times
What is the probability of crossing hospital capacity?threshold crossing is a probability across possible paths
How variable are outcomes?variance and distributions require more than one deterministic path

But doesn't the stochastic mean resemble the deterministic solution?

Sometimes it does, particularly for large populations and approximately linear behaviour. That does not make the stochastic model redundant.

Even if

\[E[I_t]\approx I_{\mathrm{det}}(t),\]

the stochastic model also describes the spread around that mean, extinction probability, tail behaviour and path-dependent outcomes.

The deterministic trajectory and the stochastic expectation answer only part of the question. A distribution contains information that its mean alone cannot contain.

And the means are not always identical

For nonlinear models, in general

\[E[f(X_t)]\ne f(E[X_t]).\]

Therefore the stochastic mean itself can differ from the deterministic trajectory. This is one reason nonlinear stochastic biological models require care.

State space

ModelTypical state representation
deterministic ODEcontinuous-valued population variables
CTMCdiscrete integer counts
SDEcontinuous-valued stochastic variables

If the true population contains 27 infectious people, the CTMC can represent exactly 27. An SDE approximation may produce \(27.4\), which should be interpreted as a continuous approximation to the count process, not as a literal fraction of a person.

How time is represented

All three models here evolve in continuous time, but they use time differently.

ModelWhat happens through time?
ODEthe state changes smoothly according to a derivative
CTMCthe state remains fixed between random event times, then jumps
SDEthe state evolves continuously with Brownian fluctuations

Continuous does not mean smooth

An SDE driven by Brownian motion can have a continuous trajectory while still being extremely irregular. There are no CTMC-style jumps, but the path is not differentiable in the ordinary sense.

This is different from the smooth trajectory of an ODE.

Population size matters

When populations are large and each event changes only a tiny fraction of the population, a continuous approximation can work well. This is the setting in which deterministic and diffusion approximations often become useful.

When counts are small, the discrete nature of events becomes much more important.

Near extinction, an SDE approximation can be problematic. It may generate non-integer or even negative values unless boundaries and numerical methods are handled carefully. A CTMC naturally preserves integer counts and exact absorbing states.

A useful scale interpretation

individual random events: CTMC→many-event continuous randomness: SDE→average population tendency: ODE

This is a conceptual progression rather than a rule that one model is always derived exactly from the model on its left.

What happens as population size becomes large?

Under suitable scaling and assumptions, random fluctuations become small relative to the population size. A CTMC can then be approximated by a deterministic model at leading order, while an SDE can retain the next level of random fluctuation around that deterministic behaviour.

This provides an important mathematical connection:

\[\text{discrete random events}\longrightarrow\text{diffusion approximation}\longrightarrow\text{deterministic limit}.\]

Computational differences

FeatureODECTMCSDE
one runone deterministic solutionone random event historyone random continuous path
random samplingnot intrinsicevent times/typesBrownian increments
typical numerical methodODE solverGillespie algorithmEuler–Maruyama or higher-order SDE method
many-run statisticsnot required for fixed parametersMonte CarloMonte Carlo

Which model should be chosen?

Choose according to the biological question and the scale at which randomness matters.

If the main concern is...A natural starting point
average population-level dynamicsdeterministic ODE
individual events, small counts or exact extinctionCTMC
continuous stochastic variability in moderately large populationsSDE
rare-event probabilitiesoften CTMC or another explicitly stochastic formulation
fast approximation to event-driven stochastic dynamicsSDE may be useful

No model is automatically “more realistic”

A more detailed stochastic model can still be poorly specified. An ODE with well-estimated mechanisms may be more useful than an SDE with arbitrary noise. Likewise, an SDE diffusion approximation may be less appropriate than a CTMC near a small-population boundary.

Model complexity should be justified by the scientific question. Adding randomness is useful when the uncertainty or event variability being represented matters to the conclusions.

The central relationship

For the SIS example, the same event rates

\[b(i)=\beta\frac{(N-i)i}{N},\qquad d(i)=\gamma i\]

lead naturally to three descriptions:

ModelWhat is retained?
ODEnet tendency \(b-d\)
CTMCseparate random events with rates \(b\) and \(d\)
SDEdrift \(b-d\) and approximate fluctuation magnitude \(\sqrt{b+d}\)
Key idea. Deterministic, CTMC and SDE models need not represent three unrelated biological stories. They can be three mathematical views of the same underlying mechanisms. The ODE emphasizes average change, the CTMC resolves discrete random events, and the SDE provides a continuous stochastic approximation that retains both drift and variability.

Compare matched implementations

The matched Python comparison uses common assumptions to show which differences arise from model type rather than mismatched parameters.

Continue along the learning path

Add spatial location, diffusion, movement and pattern formation to time-dependent biological models.

Continue to Spatial Mathematical Biology →