Analytics Vidhya
Published in

Analytics Vidhya

Modelling disease spread using a logistic model in Python

Simplified epidemic model of COVID 19

# Number people exposed to an infected person (E)
E = 1
# Probablity that an exposed person catches on the disease
p = 0.05
# Total population Size (set at 100 million)
pop = 1e8
#Total Infections by day (starts by 1 person getting infected)

Plotting the impact of Exposure

E = 1
for j in range(20):
for i in range(1,300): #100 days
N_d[i] = (1+ E*p*(1-N_d[i-1]/pop))*N_d[i-1]
E= E+1
plt.plot(N_d, label= E-1)
#plt.yscale('log')
plt.legend()
plt.show()

The number of new cases Every Day

E = 1
del_d = np.zeros(300)
for j in range(20):
for i in range(1,300): #100 days
N_d[i] = (1+ E*p*(1-N_d[i-1]/pop))*N_d[i-1]
del_d[i] = N_d[i] - N_d[i-1]
E= E+1
plt.plot(del_d, label= E-1)
#plt.yscale('log')
plt.legend()
plt.show()

Modelling with Recovery @ 1% of the population

R = 0.01
E = 1
p = 0.05
for j in range(10):
for i in range(1,300): #100 days
N_d[i] = (1+ E*p*(1-N_d[i-1]/pop))*N_d[i-1] - R*N_d[i-1]
E= E+2
plt.plot(N_d, label= "E=" + str(E-1)+" with recovery="+str(100*R) +"%")
#plt.yscale('log')

R = 0.01
E = 1
p = 0.05
for j in range(10):
for i in range(1,300): #100 days
N_d[i] = (1+ E*p*(1-N_d[i-1]/pop))*N_d[i-1] #- R*N_d[i-1]
E= E+2
plt.plot(N_d, label= "E=" + str(E-1)+" (model without recovery)")

plt.legend()
plt.show()

--

--

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store