SIR Epidemic Model Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

Introduction to the SIR epidemic model

The SIR model is a classic, deterministic compartment model for infectious disease dynamics. It starts with a susceptible pool, moves people into the infectious compartment as transmission happens, and then moves them into the removed or recovered compartment once they are no longer contagious. This calculator lets you test how quickly those shifts happen under different assumptions about β and γ.

Given starting counts 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. Because the calculator solves the equations numerically over time, it is useful for comparing scenarios rather than for pretending that every real outbreak will follow the exact same path.

SIR inputs and what each parameter controls

  • Total population (N): the size of the closed population you want to model. Everyone remains in that population throughout the run.
  • Initial infected (I₀): number of infectious people at time 0.
  • Initial recovered (R₀): the starting number already removed or recovered at time 0.
  • Initial susceptible (S₀): implied by the others: S₀ = N − I₀ − R₀. For the model to make sense, this should not be negative.
  • Infection rate (β) (per day): controls how quickly susceptible people become infected through contact with infectious people. Larger β makes the outbreak rise faster and usually lifts the peak.
  • 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 usually improve numerical stability and accuracy.
  • Steps: number of iterations. Total simulated duration is approximately Steps × Δt days.

Reading the SIR outbreak results

  • Peak infected: the maximum of I(t). This is a proxy for the largest number of people infectious at the same time.
  • Time to peak: when I(t) reaches its maximum; this shifts with β, γ, and the starting conditions.
  • Final size: how many people have ever been infected by the end of the simulation, often approximated by R(T) − R₀ using the starting recovered count as the baseline.
  • Early growth vs decline: if your initial state yields Re(0) > 1, I(t) usually rises at first; if Re(0) < 1, I(t) often falls immediately.

In planning terms, the peak tells you when the modelled outbreak is most intense, while the final size tells you how much of the population has moved through infection by the end of the run. Lowering β or raising γ both push the system toward a smaller peak and a faster decline.

Worked SIR example: one infection in a mostly susceptible population

Suppose you start with N = 1000, I₀ = 1, recovered at day 0 = 0, β = 0.3 per day, and γ = 0.1 per day. That means the initial susceptible count is 999, so almost the whole population can still be reached by transmission.

  • Basic reproduction number = β/γ = 0.3/0.1 = 3
  • Effective reproduction number at day 0 = 3 · (999/1000) ≈ 2.997, so infections grow at first.
  • Average infectious period ≈ 1/γ = 10 days

Because β is three times γ, each infectious person can, on average, replace themselves with more than one new case while almost everyone is still susceptible. As the susceptible pool shrinks, Re(t) falls, which is why the curve eventually bends over. If you cut β to 0.15 and keep γ fixed, the outbreak slows and the peak drops; if β falls below γ, the outbreak usually dies out instead of expanding.

How SIR parameters change the outbreak curve

Change Typical effect on the SIR outbreak curve Why it happens
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 and limits of the SIR model

  • Closed population: N stays constant in the model, so there are no births, migrations, or other entries and exits. 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 are represented.
  • No incubation or latent period: infections become infectious immediately, which is why SEIR models are often used when a delay matters.
  • Constant rates: β and γ are treated as fixed over time; real epidemics can change because of behavior shifts, interventions, seasonality, or waning immunity.
  • Deterministic dynamics: randomness is ignored, so 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: SIR model equations (continuous time)

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

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

These equations assume homogeneous mixing and a transmission term proportional to S·I/N, so the infection pressure weakens as S falls.

Numerical integration for the SIR equations

This calculator advances the SIR equations through discrete time steps of size Δt and offers two solvers for that job.

Forward Euler

The simplest approach: evaluate derivatives at the current SIR 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 SIR derivatives at four points within each step and combines them in a weighted average. For most outbreak scenarios, RK4 gives a smoother and more reliable trajectory than Euler at modest computational cost. It is the better choice when you care about peak timing or want a cleaner numerical curve.

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

Key SIR-derived quantities

  • Basic reproduction number: R₀ = β/γ. If R₀ > 1 and most people are susceptible, the outbreak can initially grow; if R₀ < 1, it tends 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.

Reporting checklist for SIR simulations

  • 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 show how robust the peak timing and final size are.
  • Model scope: explicitly state that this is a homogeneous-mixing deterministic SIR model.

How to use this SIR epidemic model calculator

  1. Enter Total population N for the outbreak setting you want to model.
  2. Enter Initial infected I₀ as the starting number of infectious people.
  3. Enter Initial recovered R₀ as the number already removed or recovered at day 0.
  4. Run one SIR scenario, then change β, γ, or the starting cases and compare how the outbreak curve shifts before drawing conclusions.

Arcade Mini-Game: Stress-Test an SIR Scenario

Use this quick arcade run to practice spotting SIR inputs that matter most—especially the starting cases, β, and γ—before you trust the curve.

Score: 0 Timer: 30s Best: 0

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

Enter SIR parameters and simulate the outbreak curve.