SIR model

[17]:
from epistochmodels import SIR, SIR_Dem
[18]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib
[19]:
pop = 1000
beta = 0.7
gamma = 0.2
model = SIR(pop,beta,gamma)
[20]:
model.initialize(990,10,0)
[21]:
%%time
res = model.run(0,1000)
CPU times: user 2.66 ms, sys: 0 ns, total: 2.66 ms
Wall time: 2.67 ms
[22]:
plot(res[0],res[1])
legend(['S','I','R']);
grid();
../_images/notebooks_SIR_6_0.svg
[23]:
pop2 = 1000
alpha = 0.05 # Mortality rate
model2 = SIR_Dem(pop2, alpha,beta,gamma)
[24]:
model2.initialize(990,10,0)
[25]:
%%time
res2 = model2.run(0,100)
CPU times: user 37.6 ms, sys: 7.04 ms, total: 44.6 ms
Wall time: 43 ms
[26]:
plot(res2[0],res2[1])
legend(['S','I','R']);
grid()
../_images/notebooks_SIR_10_0.svg
[ ]: