AMidlige Tutorial 10#1
Conversation
| N0=10 | ||
| times=range(0,1000) | ||
|
|
||
| modelSim=spint.odeint(func=growthRate,y0=N0,t=times,args=params) |
There was a problem hiding this comment.
Add modelSim and store the output in a dataframe into the loop. So you can store and print out:
rs=[-0.1,0.1,0.4,0.8,1]
store_rs=pandas.DataFrame({"time":times,"r1":0,"r2":0,"r3":0,"r4":0,"r5":0})
for i in range(0,len(rs)):
pars=(rs[i],K)
sim=si.odeint(func=ddSim,y0=y0,t=times,args=pars)
store_rs.iloc[:,i]=sim[:,0]
ggplot(store_rs,aes(x="time",y="r1",color="-0.1"))+geom_line()+geom_line(aes(x="time",y="r2",color="0.1"))+geom_line(aes(x="time",y="r3",color="0.4"))+geom_line(aes(x="time",y="r4",color="0.8"))+geom_line(aes(x="time",y="r5",color="1.0"))+theme_classic()+labs(x="time",y="N")
-0.1 pts
| modelOutput=pandas.DataFrame({"t":times,"N":modelSim[:,0]}) | ||
| b=ggplot(modelOutput,aes(x="t",y="N"))+geom_line()+theme_classic() | ||
| b.draw() | ||
|
|
| modelSim=spint.odeint(func=popSize,y0=N0,t=times,args=params) | ||
| modelOutput=pandas.DataFrame({"t":times,"N":modelSim[:,0]}) | ||
| c=ggplot(modelOutput,aes(x="t",y="N"))+geom_line()+theme_classic() | ||
| c.draw |
| return dSdt | ||
| return dIdt | ||
| return dRdt | ||
|
|
There was a problem hiding this comment.
def disTrans(y,t,beta,gamma):
S=y[0]
I=y[1]
R=y[2]
dSdt=-betaIS
dIdt=betaIS-gammaI
dRdt=gammaI
return [dSdt,dIdt,dRdt]
| a=ggplot(modelOutput,aes(x="t",y="y0"))+geom_line(aes(x="t",y="S"),color='blue')+geom_line(aes(x="t",y="I"),color='red')+geom_line(aes(x="t",y="R"),color='green')+theme_classic() | ||
| a.draw() | ||
|
|
||
| for i in I.modelOutput: |
|
|
||
| for i in modelOutput: | ||
| reproductionNumber= beta[i]* (S(i)+ I(i)+ R(i)) / gamma[i] | ||
|
No newline at end of file |
No description provided.