Buynak-Yingying Submission#7
Conversation
| params=(0.3,10) | ||
| N0=[1] | ||
| times=range(0,100) | ||
| ks=["0,10","0,50","0,100"] |
| N0=[1] | ||
| times=range(0,100) | ||
| ks=["0,10","0,50","0,100"] | ||
| r=[0.2] |
| beta=0.0005 | ||
| gamma=0.05 | ||
| #time (days) | ||
| t = np.linspace(0, 500, 500) |
There was a problem hiding this comment.
Set t = 0 to 500?
t = np.linspace(0, 500, 501)
| print('iList', iList) | ||
| print('rList', rList) | ||
| print('newIList', newIList) | ||
|
|
There was a problem hiding this comment.
Define the function:
def simSIR(y,t,beta,gamma):
S=y[0]
I=y[1]
R=y[2]
dSdt=-betaIS
dIdt=betaIS-gammaI
dRdt=gammaI
return [dSdt,dIdt,dRdt]
Define the parameters:
y0=[999,1,0]
times=range(0,500)
betas=numpy.array([0.0005,0.005,0.0001,0.00005,0.0001,0.0002,0.0001])
gammas=numpy.array([0.05,0.5,0.1,0.1,0.05,0.05,0.06])
Make a new dataframe to store the parameters:
storeSIR=pandas.DataFrame({"beta":betas,"gamma":gammas,"R0":betas*sum(y0)/gammas,"maxIncidence":0,"maxPrevalence":0,"percentAffected":0})
Using the for loop to simulate:
for i in range(0,len(betas)):
pars=(betas[i],gammas[i])
sim=si.odeint(func=simSIR,y0=y0,t=times,args=pars)
storeSIR.iloc[i,4]=numpy.max(sim[:,1]/numpy.sum(sim,axis=1))
storeSIR.iloc[i,3]=numpy.max(sim[1:len(sim),1]-sim[0:(len(sim)-1),1])
storeSIR.iloc[i,5]=numpy.sum(sim[len(sim)-1,1:3])/numpy.sum(sim[len(sim)-1,:])*100
-0.5 pts
No description provided.