SIR Epidemic Model Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

Introduction: Overview

The SIR model is a classic, deterministic compartment model for infectious disease dynamics. It divides a closed population into three groups:

Given initial conditions and two rate parameters—β (infection/transmission rate) and γ (recovery/removal rate)—the model produces an “epidemic curve”: infections rise, peak, and then fall as susceptibility is depleted. This calculator simulates that curve numerically over time using a discrete time step.

What the inputs mean

  • Total population (N): the total number of people in the modeled population. In a basic SIR model, N stays constant.
  • Initial infected (I₀): number of infectious people at time 0.
  • Initial recovered (R₀): number of removed/recovered people at time 0.
  • Initial susceptible (S₀): implied by the others: S₀ = N − I₀ − R₀. For the model to make sense you should have N ≥ I₀ + R₀.
  • Infection rate (β) (per day): controls how quickly susceptible people become infected through contact with infectious people. Larger β makes outbreaks grow faster and peak higher (all else equal).
  • Recovery rate (γ) (per day): controls how quickly infectious people leave the I compartment. The average infectious period is approximately 1/γ days.
  • Time step (Δt) (days): the simulation increment. Smaller values generally improve numerical stability/accuracy.
  • Steps: number of iterations. Total simulated duration is approximately Steps × Δt days.

How to interpret results

  • Peak infected: the maximum of I(t). This is a proxy for maximum concurrent infectious burden.
  • Time to peak: when I(t) reaches its maximum; depends strongly on β and γ.
  • Final size: how many people have ever been infected by the end of the simulation, often approximated by R(T) − R₀ (assuming recovered represent cumulative infections in the basic model).
  • Early growth vs decline: if your initial state yields Re(0) > 1, I(t) will initially increase; if Re(0) < 1, I(t) typically decreases immediately.

To explore interventions conceptually, lowering β (reduced contact/transmission) or raising γ (faster recovery/isolation) reduces R₀ and tends to reduce the peak and total infections.

Worked example

Suppose:

  • N = 1000
  • I₀ = 1
  • R₀ = 0 → S₀ = 999
  • β = 0.3 per day
  • γ = 0.1 per day

Then:

  • R₀ = β/γ = 0.3/0.1 = 3
  • Re(0) = 3 · (999/1000) ≈ 2.997 > 1, so infections initially grow.
  • Average infectious period ≈ 1/γ = 10 days.

If you run the simulation long enough, I(t) will rise from 1, reach a peak, and eventually fall as S(t) declines and Re(t) drops below 1. Try decreasing β to 0.15 (keeping γ = 0.1): R₀ becomes 1.5 and the peak should be smaller and later; decreasing β below 0.1 makes R₀ < 1 and I(t) typically shrinks from the start.

Parameter comparison (what changes when you adjust inputs)

Change Typical effect on the epidemic curve Why
Increase β Faster growth, higher and earlier peak; larger total infected More transmission per S–I contact increases incidence
Decrease β Slower growth, lower peak; may prevent a major outbreak Reduces R₀ and Re(t)
Increase γ Lower peak and shorter outbreak duration People leave I faster (shorter infectious period)
Increase I₀ Earlier visible outbreak; peak may occur sooner More initial infectious seed accelerates early dynamics
Decrease Δt More stable/accurate numerical trajectory (slower to compute) Reduces discretization error from Euler steps

Assumptions & limitations

  • Closed population: N is constant (no births, migration). Deaths are not modeled separately unless you interpret “removed” as including deaths.
  • Homogeneous mixing: everyone is equally likely to contact everyone else; no households, networks, age structure, or geography.
  • No incubation/latent period: infections become infectious immediately (contrast with SEIR models).
  • Constant rates: β and γ are treated as fixed over time; real epidemics have changing behavior, seasonality, interventions, and waning immunity.
  • Deterministic dynamics: randomness is ignored; small outbreaks in small populations can differ substantially from deterministic predictions.
  • Numerical approximation: Euler stepping can introduce error; very large Δt may produce unstable or unrealistic values.
  • Not medical advice: this tool is for education and scenario exploration, not for clinical or public-health decision making.

Reference: Kermack, W.O. & McKendrick, A.G. (1927). “A Contribution to the Mathematical Theory of Epidemics.”

Formula: Model equations (continuous time)

The standard SIR differential equations (Kermack–McKendrick) are:

dSdt = βSIN dIdt = βSINγI dRdt = γI

These equations assume that transmission is proportional to the product S·I (homogeneous mixing) and scaled by 1/N.

Numerical integration methods

This calculator offers two numerical solvers to advance the SIR equations through discrete time steps of size Δt.

Forward Euler

The simplest approach: evaluate derivatives at the current state and step forward linearly.

  • Sn+1 = Sn − Δt · β · Sn In / N
  • In+1 = In + Δt · β · Sn In / N − Δt · γ · In
  • Rn+1 = Rn + Δt · γ · In

Euler is fast but first-order accurate. Large Δt can cause overshooting and produce unrealistic values (e.g., negative S or I), especially when β is high.

Runge–Kutta 4 (recommended)

The classical fourth-order method evaluates the derivatives at four points within each step and combines them in a weighted average. For most applications, RK4 provides substantially better accuracy than Euler at modest computational cost. It is the recommended choice for quantitative work and publication-quality results.

The calculator reports a population conservation diagnostic |S+I+R−N| so you can verify numerical integrity regardless of solver choice.

Key derived quantities

  • Basic reproduction number: R₀ = β/γ. If R₀ > 1 and most people are susceptible, infections can initially grow; if R₀ < 1, infections tend to die out.
  • Effective reproduction number: Re(t) = (β/γ) · (S(t)/N). Even with R₀ > 1, Re(t) declines as S decreases; the epidemic starts shrinking once Re(t) drops below 1.
  • Average infectious duration: about 1/γ days.

Research-quality reporting checklist

  • Numerical method disclosure: report whether you use Euler or RK4 and the exact step size Δt.
  • Reproducibility: report all initial conditions (N, S₀, I₀, R₀), β, γ, horizon, and solver choice.
  • Stability diagnostics: track population conservation error |(S+I+R)−N| and verify it remains small.
  • Sensitivity analysis: vary β, γ, and Δt to demonstrate robustness of peak timing and final size.
  • Model scope: explicitly state that this is a homogeneous-mixing deterministic SIR model.

How to use this calculator

  1. Enter Total population N using the unit or time period shown by the field.
  2. Enter Initial infected I₀ using the unit or time period shown by the field.
  3. Enter Initial recovered R₀ using the unit or time period shown by the field.
  4. Run the calculation and compare the output with a second scenario before acting on it.

Arcade Mini-Game: SIR Epidemic Model Calculator Calibration Run

Use this quick arcade run to practice separating useful scenario inputs from common planning mistakes before you rely on the calculator output.

Score: 0 Timer: 30s Best: 0

Start the game, then use your pointer or arrow keys to catch useful inputs and avoid bad assumptions.

Enter parameters and simulate disease progression.