C.G.
5-13-22
The SIR model is used by epidemiologists
Note that n is population
Uses a system of differential equations
beta = .0005; # Beta coefficient.
gamma = .00048; # Gamma coefficient.
dt = 0.5; # Change in time.
N = 1000; # Number of times the equations will update.
# Time vector
t = linspace(0, N*dt, N+1);
# Zero vectors for S, I, R
S = zeros(N+1, 1);
I = zeros(N+1, 1);
R = zeros(N+1, 1);
# Initial condition
S(1) = 100;
I(1) = 1;
R(1) = 0;
# The forward equations used to find futier values of S, I, R
for n = 1:N
S(n+1) = S(n) - dt*beta*S(n)*I(n);
I(n+1) = I(n) + dt*beta*S(n)*I(n) - dt*gamma*I(n);
R(n+1) = R(n) + dt*gamma*I(n);
end
# Ploting the S, I, R graph (I should be a graph but for some reason it prints 3)
plot(t, S, t, I, t, R);
legend('S', 'I', 'R', 'Location','northeast');
xlabel('time');
ylabel('S, I, R Populations')
print('tmp', '-dpdf'); print('tmp', '-dpng');
Image just in case :)
This output of my code was made using https://octave-online.net/
The Program runs for small beta and small gamma however for real values it brakes and it prints three graphs…
Brauer, Fred. “Mathematical Epidemiology: Past, Present, and Future.” Infectious Disease Modelling, KeAi Publishing, 4 Feb. 2017, https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6001967/.
Discrete Sir Models Influenza - San Diego State University. https://jmahaffy.sdsu.edu/courses/f17/math636/beamer/sir.pdf.
Our textbook and homeworks