using Measurements
param_error = 0.05
α = 0.2 ± param_error
γ = 0.5 ± param_error
# β = f(social distancing, masks, etc.)
E₀ = 1e-4
u₀ = [ 1 - E₀ ; E₀ ; 0 ; 0 ]
tspan = (0.0, 200.0); # 200 days
using DifferentialEquations
function seir!(du,u,p,t)
S,E,I,_ = u
α,β,γ = p
dS = ( -β*I*S )
dE = ( +β*I*S ) - α*E
dI = ( -γ*I ) + α*E
dR = ( +γ*I )
du .= (dS, dE, dI, dR)
end
labels = [
"Susceptible", "Exposed",
"Infected", "Recovered"
];
using SimplePlots
display(html"""
<h3> Sliding the β value reduces/increases infectivity </h3>
<p style="margin-top: 0.4em">(social distancing, immunity, vaccines reduce β)</p>
""")
beta_slider = slider(0.25:0.25:2, value=1, label="β")
@demo for β in beta_slider
title!("Covid-19 SEIR Model with Error Bars") ;
xlabel!("Time (Days)") ; ylabel!("%")
soln = solve(ODEProblem(
seir!, u₀, tspan, [α, β ± param_error, γ]
), saveat=0.5)
x, y = soln.t, 100*Array(soln)
ylims!(0, 100) # using percentages
for (index, label) in enumerate(labels)
plot!(
x, y[index,:], label=label,
alpha=0.8, fillalpha=0.1
)
end
end
(social distancing, immunity, vaccines reduce β)