Recently I saw a picture of SIR epidemic model posted on the Internet. Many people should not know much about this model. Let’s talk about this model today. This article is only about academic research, and does not discuss anything else.

SIR model is one of the most classic models of infectious diseases. There are two similar models, Si and sis. Sir is the acronym of three words, s is the abbreviation of susceptible, which means susceptible; I is the abbreviation of infectious, which means infected; R is the abbreviation of removal, which means removed.**The model itself is to study the relationship among the three. At the beginning of the virus, all people are susceptible, that is, all people are likely to be infected with the virus; when some people are exposed to the virus, they become infected; the infected will receive various treatments, and finally they become removed.**The relationship among the three is shown in the figure below

At the beginning of the virus, s = n, then s changes to I at the rate of daily α, and I changes to R at the rate of daily β

```
N(t) = S(t) + I(t) + R(t)
S(t+1) = S(t) - αS(t)
I(t+1) = I(t) - βI(t)
R(t+1) = R(t) + βI(t)
```

If we want to get the number of S, I and R corresponding to a certain time t, we need to know the values of α and β, as well as the values of S0 and I0. This model can be implemented in Python, and the specific code is as follows:

```
%matplotlib inline
import scipy.integrate as spi
import numpy as np
import pylab as pl
alpha=1.4247
beta=0.14286
TS = 1.0 # observation interval
Nd = 70.0 # observation end date
S0 = 1-1e-6 # initial susceptible population
I0 = 1e-6 # number of initial infection
INPUT = (S0, I0, 0.0)
def diff_eqs(INP,t):
'''The main set of equations'''
Y=np.zeros((3))
V = INP
Y[0] = - alpha * V[0] * V[1]
Y[1] = alpha * V[0] * V[1] - beta * V[1]
Y[2] = beta * V[1]
return Y
t_start = 0.0
t_end = ND
t_inc = TS
t_ range = np.arange (t_ start, t_ end+t_ inc, t_ INC) # generation date range
RES = spi.odeint(diff_eqs,INPUT,t_range)
pl.subplot(111)
pl.plot(RES[:,0], '-g', label='Susceptible')
pl.plot(RES[:,1], '-r', label='Infective')
pl.plot(RES[:,2], '-k', label='Removal')
pl.legend(loc=0)
pl.title('SIR_Model')
pl.xlabel('Time')
pl.ylabel('Numbers')
pl.xlabel('Time')
```

Finally, running the above code can get the following result graph, which shows a change trend of the number of S, I, R with the change of time t.

This model has two assumptions

1. In a period of time, the total number of people n is constant, that is, the number of new students and natural deaths are not considered

2. The rate of change α from s to I and β from I to r also remain unchanged

In the actual environment, the above two assumptions are generally not easy to meet, so the results will deviate from the actual data.