411 REFERENCE · Wikibooks
Scientific Calculations with Julia/SIR Model
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Scientific Calculations with Julia SIR Model Diagnosing Heart Disease Predator-Prey Model
The SIR model is a simple compartmental model for the dynamics of an infectious disease. The population is divided into three classes:
: susceptible
: infected
: removed (recovered or immune)
The equations are:
Where is the transmission rate and is the recovery rate.
The curve of susceptible individuals S(t) tends to decrease, while the curve of infected individuals I(t) grows rapidly (exponential phase), reaching a well-defined peak and then decreasing as the pool of susceptible individuals has sufficiently reduced, tending to 0. The curve of those removed (recovered or immune) R(t) increases, reaching its maximum.
The transmission rate measures the speed with which a susceptible individual comes into contact with an infected individual and contracts the disease. The larger the , the faster the infection spreads.
The recovery rate measures the speed with which infected individuals recover (or are removed from the epidemic because they are immune or die). The larger the , the faster the infection subsides.
The parameter determines whether the epidemic tends to grow or die out:
If , the epidemic tends to grow.
If , the epidemic tends to die out.
Realistic example:
Seasonal influenza: ,
COVID-19 (initial strain): ,
Julia Example
If the epidemic lasts 160 days, the initial conditions of the system of differential equations u0 give 99% susceptible, 1% infected, and 0% recovered or immune, with a transmission rate of 0.5 and a recovery rate of 0.1, then R0 = 5, so the epidemic grows, reaching a peak, as shown in the following Julia graph, obtained by solving the system of equations. differentials:
using DifferentialEquations
using Plots
function SIR!(du, u, p, t)
S, I, R = u
β, γ = p
du\[1] = -β \* S \* I
du\[2] = β \* S \* I - γ \* I
du\[3] = γ \* I
end
β = 0.5
γ = 0.1
p = (β, γ)
u0 = \[0.99, 0.01, 0.0]
tspan = (0.0, 160.0)
prob = ODEProblem(SIR!, u0, tspan, p)
sol = solve(prob, Tsit5())
plot(sol, xlabel="Days", ylabel="Fraction of population",
label=\["Healthy" "Infected" "Recovered"], lw=2)
thumb|left|600px