# Demo entry 6322090

ghj

Submitted by anonymous on Nov 11, 2016 at 21:07
Language: Python 3. Code size: 958 Bytes.

```def SEIR(X,T,beta,mu,a,gamma,N):
for i in range (T) :
S=X[0]
E=X[1]
I=X[2]
R=X[3]
X[0]=S-beta*S*I/N + mu*N - mu*S
X[1]=E + beta*S*I/N - (mu+a)*E
X[2]=I+ a*E - (gamma + mu)*I
X[3]=R+ gamma*I - mu*R

R0=beta*gamma/((mu+a)*(gamma+mu))
return X,R0

import matplotlib.pyplot as plt
X=[99,0,1,0]
T=100
beta=1
mu=0.01
a=1
gamma=0.4
N=100
S=[]
E=[]
I=[]
R=[]
for i in range(T):#on va effectuer la boucle T fois
C=SEIR(X,i,beta,mu,a,gamma,N) # On applique la fonction seir au temps i
X=C[0]	#on recupere le X renvoyer par la fonciton SEIR
S.append(X[0])	#on recupre le S du vecteur X
E.append(X[1])
I.append(X[2])
R.append(X[3])

temps=[i for i in range(T)]

plt.plot(temps,S,label="S")
plt.plot(temps,E,label="E")
plt.plot(temps,I,label="I")
plt.plot(temps,R,label="R")
plt.xlabel('Temps')
plt.legend()
plt.show()
```

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.