Skip to content

AMidlige Tutorial 10#1

Open
amidlige wants to merge 5 commits into
lyy005:masterfrom
amidlige:master
Open

AMidlige Tutorial 10#1
amidlige wants to merge 5 commits into
lyy005:masterfrom
amidlige:master

Conversation

@amidlige

@amidlige amidlige commented Nov 9, 2017

Copy link
Copy Markdown

No description provided.

Comment thread tutorial10part1.py
N0=10
times=range(0,1000)

modelSim=spint.odeint(func=growthRate,y0=N0,t=times,args=params)

@lyy005 lyy005 Nov 24, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread tutorial10part1.py
modelOutput=pandas.DataFrame({"t":times,"N":modelSim[:,0]})
b=ggplot(modelOutput,aes(x="t",y="N"))+geom_line()+theme_classic()
b.draw()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the last plot

Comment thread tutorial10part1.py
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

@lyy005 lyy005 Nov 24, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the last plot

Comment thread tutorial10part2.py
return dSdt
return dIdt
return dRdt

@lyy005 lyy005 Nov 26, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def disTrans(y,t,beta,gamma):
S=y[0]
I=y[1]
R=y[2]
dSdt=-betaIS
dIdt=betaIS-gammaI
dRdt=gamma
I
return [dSdt,dIdt,dRdt]

Comment thread tutorial10part2.py
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:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for i in modelOutput:

Comment thread tutorial10part2.py

for i in modelOutput:
reproductionNumber= beta[i]* (S(i)+ I(i)+ R(i)) / gamma[i]

No newline at end of file

@lyy005 lyy005 Nov 26, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-0.25 pts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants