# Modelling disease spread using a logistic model in Python

# Simplified epidemic model of COVID 19

The infections on day n+1 are calculated as

*N_d* is the current infected population, pop is the total susceptible population, *E *is the Number of people exposed to an infected person per day and *p*

is the probablity that an exposed person catches on the disease.

The (1-N_d/pop) factor indicates that as a larger and larger fraction is exposed, the probability that the new person being exposed is “not infected” goes down.

Assuming the following:

*# 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

These are for various values of the “number of people exposed, E”. Each line is for a certain value of E, the left most is for 20 people exposed to each other every day, the right most is 1 person exposed every day. Huge difference.

`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

This can be modelled as the gradient of the curves above. This what is meant by “flattening the curve”. Compare E =1 (right most) with E = 20 (left most)

`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

This models recovery as well (1% of the infected populace recovers/dies every day, and hence is no longer infected). Letgamma be the recovery rate.

`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()

Stay safe everyone. Keep E low, that’s the only variable you can control.