generated from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
099_02_debug_stochastic.py
85 lines (52 loc) · 1.02 KB
/
099_02_debug_stochastic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python
# coding: utf-8
# # More Debugging Stochastic Models
#
# In[1]:
#hide
#skip
get_ipython().system(' [ -e /content ] && pip install -Uqq pyndamics3 emcee # upgrade pyndamics3 on colab')
# In[2]:
get_ipython().run_line_magic('pylab', 'inline')
# In[3]:
from pyndamics3 import Simulation,Stochastic_Simulation
# In[7]:
So=5364500
So=100
Eo=1
Io=0
β=0.2
q=2
ρ=1/5
γ=1/7
ts=130
sim=Simulation()
sim.add("S'=-β*S*I/N",So)
sim.add("E'=+β*S*I/N-ρ*E",Eo,plot=1)
sim.add("I'=+ρ*E-γ*I",Io,plot=1)
sim.add("R'=+γ*I",0)
sim.add("N=S+E+I+R")
sim.params(β=β,γ=γ,q=q,ρ=ρ,ts=ts)
sim.run(400)
# In[19]:
So=5364500
#So=100000
Eo=1
Io=0
β=0.2
q=2
ρ=1/5
γ=1/7
ts=130
sim=Stochastic_Simulation()
sim.add("-S+E",'β*S*I/N',S=So,E=Eo,I=Io)
sim.add("-E+I",'ρ*E')
sim.add("-I+R",'γ*I',R=0)
sim.add("N=S+E+I+R")
sim.params(β=β,γ=γ,q=q,ρ=ρ,ts=ts)
sim.run(500,Nsims=100)
# In[20]:
for i in range(100):
plot(sim.t,sim.E[i],'bo',alpha=0.05)
plot(sim.t,sim.I[i],'ro',alpha=0.05)
# In[ ]: