Last active
April 4, 2020 17:16
-
-
Save Nick3523/f8434c95175c9b8b244515814e68cbf0 to your computer and use it in GitHub Desktop.
Simulation pédagogique de l'évolution de la pandémie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import matplotlib.pyplot as plt | |
X = 50 | |
X0 = 30 | |
L = 30000 | |
K = 0.5 | |
#X indique le temps, supposons qu'il commence au jour 0 et s'arrête après 50 jours. | |
#X0 indique le moment où la croissance exponentielle s'arrête, disons après 30 jours. | |
#L indique la valeur maximale pouvant être par la courbe, disons 4.5 10^-4 de la population française, soit 30000 | |
#K indique la pente de la courbe : disons 0.5 | |
##Functions | |
def f(L, X, X0, K): | |
return (L / (1+math.exp(-K * (X-X0)))) | |
def coronaEvolution(L, X0, K, X): | |
res = [] | |
for t in range(X) : | |
res.append(f(L, t, X0, K)) | |
return res | |
##Programm Run : | |
####One Simulation : | |
sim1 = coronaEvolution(L, X0, K, X) | |
plt.plot(sim1) | |
plt.ylabel('Nombre de personnes infectées') | |
plt.xlabel('Jours') | |
plt.show() | |
####More Simulations : | |
nbSimulations = 5 | |
plt.ylabel('Nombre de personnes infectées') | |
plt.xlabel('Jours') | |
for i in range(nbSimulations): | |
plt.plot(coronaEvolution(L, X0*(1+(i/nbSimulations)), K+(i/nbSimulations), X), label="Scénario=%d"%(i+1,)) | |
leg = plt.legend(loc='upper left', ncol=1, mode=None, shadow=False, fancybox=False) | |
leg.get_frame().set_alpha(0.9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment