Educational research project

How does an epidemic spread? See for yourself.

A model of how a disease moves through a city — accounting for a hidden (incubation) period. Change the parameters, introduce quarantine — and see what happens. Right in your browser.

5 groupssusceptible · exposed · infected · recovered · deceased
RK4precise step-by-step calculation
0 installsruns right in your browser

Simulator

Pick a disease and watch how it spreads.

  1. Pick a disease
  2. Move the sliders
  3. Watch the chart change

Pick a scenario and see how different diseases behave differently.

hover over the chart

Susceptible (S)Exposed (E)Infected (I)Recovered (R)Deceased (D)Real dataIf nothing had been doneStart of measures
R₀ — how many people one infected person infects
Peak: sick at the same time
Peak dayfrom start
Total who will get sick
Will die
Measures and vaccination will save

Comparison with real data

Paste the number of sick people per day (one number per line, or "day,value") — the model will overlay a curve on it. "Fit β" will automatically find the best match.

How to read the result

RMSE is the model's average error in people: the smaller, the more accurate. If the curve still doesn't match even after fitting, something in real life isn't captured by the model.

The "Sample data" is synthetic (generated by the model with added noise) and calculated for a population of 100,000.

How the model works

The idea is simple: everyone is divided into five groups and moves from one to another.

R₀ is how many people, on average, one infected person infects. Above 1 — the epidemic grows; below 1 — it dies out on its own. The more people who have already recovered (or died), the harder it is for the disease to find new victims, and the wave subsides.

Show formulas

N is the total number of people initially, β is the transmission rate, σ is the rate of leaving the hidden period (σ = 1 / length of hidden period), γ is the rate of leaving the infected group (recovery or death), CFR is the fatality rate (share of infected who die).

dS/dt = −β · S · I / (N−D)dE/dt = β · S · I / (N−D) − σ · EdI/dt = σ · E − γ · IdR/dt = γ · (1−CFR) · IdD/dt = γ · CFR · I R₀ = β / γ, γ = 1 / (infectious period), σ = 1 / (hidden period)

Infection is calculated based on the number of people still alive (N−D) — the deceased can neither get infected nor infect others. The epidemic dies out once immunity (recovered or died) covers a share of 1 − 1/R₀ of the population. At CFR = 100% and a sufficiently high R₀, (almost) the entire population can die out. The calculation uses the 4th-order Runge–Kutta method (RK4) with a step of 0.1 days.

What the model doesn't account for

  • Everyone interacts with everyone else equally.
  • During the hidden period a person is assumed to be completely non-contagious — in reality, for some diseases (e.g. COVID-19), people can be contagious even before symptoms appear.
  • Immunity lasts forever; there's no reinfection.
  • People don't change their own behavior.

Be careful with the data

  • Reported cases aren't all real infections.
  • Scenarios are illustrations, not medical forecasts.
  • In small groups outbreaks are random, while the model always calculates the same way.