Section: Data Fetching

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

In this document I have described the intention and the code(in bold)

1. Covid-19 is something which is breathing around our neck for quite a some time. Now We
have the statistics of the state and it is time to analysis the data and predict when these all
will come to an end.
That is why here is the SIR model of COVID-19 and predict when we have everyone
recovered.

Section: Data Fetching


% Url of our data source is given
url="https://api.covid19india.org/csv/latest/state_wise_daily.csv";
%reading of the URL by webread function is used.
record=webread(url);
%date is recorded .
date=datetime(record.Date,'inputformat','DD-MM-YYYY');

In this snippet, The given URL is read and date is extracted by using datetime command;

Section: Data processing


1. [row,~]=size(record);
2. r=1;
3. for i=1:3
4. for index=row:-3:2
D_R_C(r,i)=record.WB(index);
r=r+1;
5. end
6. row=row-1;
7. r=1;
8. end
9. totalcases=cumsum(D_R_C(:,3));
10. totalrecovered=cumsum(D_R_C(:,2));
11. totaldeaths=cumsum(D_R_C(:,1));
12. totalactive=totalcases(end)-(totalrecovered(end)+ totaldeaths(end));

In this section,data is processed

1. row is the size of the record where the data of West Bengal is stored.
2. r is assigned 1
3. for loop is defined
4. 2nd for loop defined
5. the body of the loop has D_R_C, which is a 3 column*row matrxis where
D=deceased,so all the deceased are stored,R=recovered,all recover
personel according to each date is stored and C=confirmed where all a
confirmed cases are being stored.
6. End of 2nd for
7. Decrementing row;
8. End of 1st for loop
9. 9,10,11 line, the cumulitive sum of Death,Recovered and Confirmed has
been calculated and stored which gives the total number of any case from
the beginning on a each date
13. The active case is calculate.

Section: Conclusion and Determining the Susceptible


1. total_pop=102741588;
2. percentage_affected=(totalcases(end)/total_pop)*100;
3. fprintf("Affected percentage of total population is %d
\n",percentage_affected);
4. sus_percentage=percentage_affected*30;
5. sus=((total_pop-totalcases(end))/100)*sus_percentage;
6. fprintf("considering susceptible as 30 times of the current affected
people: %d\n",sus);
7. sus_c=total_pop*10/100;

In this section,
1. total_pop count is taken(population of Bengal)
2. In totalcases, the total confirmed case of each date starting from 1 st day is stored,
So, the last date i.e totalcases(end) will give the recent total confirmed case. Now this
information is used to calculate the percentage of total cases out of population is
calculated.
3. The percentage is displayed.
4. Now, the percentage of susceptible is taken as 30 times of the affected percentage
5. Susceptible is calculated and stored in variable sus
6. Value of sus is displayed.
7. Sus_c is stored with 10 percent of total population who are not immune to
virus(Assumption)

Section: Calculation transmission rate


1. for u=1:1:size(D_R_C(:,3))
factor(u)=D_R_C(u,3)/sus_c;
sus_c=sus_c-D_R_C(u,3);

end
2. avg=sum(factor)/length(factor);

In this section the transmission rate is calculated


1. In the for loop u is driven from1 to length of D_R_C third column, all row.
Inside D_R_C(:,3), in each row the confirmed case of that particular day is stored.
So, dividing the value of each row with sus_c(10 percent of total polpulation), the factor
of people who is infected everyday is calculated and stored in factor.
2. The average of fator is calculated which is later assigned to transmission ratio.

Section: Calculation recovery rate


1. for count1=1:length(D_R_C(:,2))
2. suum2(count1)=(D_R_C(i,2)/(totalcases(count1)-totaldeaths(count1)));
3. End

In this section, recovery ratio is calculated.


1. For loop of length of recovered column of D_R_C
The ratio of recovery on each day divided by totalcase-totaldeath, which gives as total
active. So, we have the factor of recovery on each day.

Section: Time Calculation


This Section is self explainotory, the desired date of analysis input is taken and accordingly, the time
is selected.

Section: Modelling the equation


1. transmission_ratio=avg;
2. recover_ratio=sum(suum2)/length(D_R_C(:,2));
3. t=1:1:tmax;
4. Nt=length(t);
5. I=zeros(1,tmax);
6. S=zeros(1,tmax);
7. R=zeros(1,tmax);
8. a=transmission_ratio;
9. b=recover_ratio;
10. I(1)=totalactive;
11. S(1)=sus;
12. for it=1:Nt-1
13. if(S(it)+I(it)+R(it)>=total_pop )
fprintf("here %d",it);
break;
end
14. ds(it)=-1*a*S(it)*I(it);
15. S(it+1)=S(it)+ds(it);
16. dI(it)=a*S(it)*I(it)-b*I(it);
17. I(it+1)=I(it)+dI(it);
18. dR(it)=b*I(it);
19. R(it+1)=R(it)+dR(it);
End

In this section equation is modelled


1. Value of transmision_ratio is assigned.
2. Value of recover ratio is assigned.
3. Range of t is set
4. Length of t is stored.
5. I (Infected) vector is initialized.
6. S (Susceptible) vector is initialized.
7. R (Recovered) vector is initialized.
8. a is assigned with transmission ratio
9. b is assigned with recover ratio
10. The initial value of I is assigned as totalactive
11. Intial value of Susceptible is assigned as sus
12. For loop
13. If condition is to check if the sum of S,I,R is below the total population
14. The ds/dt formula is written [latex]\frac{\mathrm{d}^{} s}{\mathrm{d} t^{}}=- a*S(t)I(t)
15. The S of nex index is updated with ds, S(it+1)=S(it)+\frac{\mathrm{d}^{} s}{\mathrm{d} t^{}}
16. The di/dt formula is written as, \frac{\mathrm{d}^{} I}{\mathrm{d} t^{}}=aS(t)I(t)-bI(t)
17. I is updated as S,
18. dr/dt is written as \frac{\mathrm{d}^{} S}{\mathrm{d} t^{}}= bI(t)
19. R is updated.

Section: Plotting
plot(range_day,S,'y');

hold on;

plot(range_day,I,'R');

hold on;
plot(range_day,R,'g');
legend("Susceptible","Infected","Recovered","Location","best");

Plotting is done for each S,I,R

Section: Result
SUS_end=double.empty(tmax,0);
INFE_end=double.empty(tmax,0);
SUS_end=range_day(1==double(30>round(S)));
INFE_end=range_day(1==double(30>round(I)));
if(length(INFE_end)>1)
fprintf("on %s All infected will be recovered\n",INFE_end(1));
end
if(length(SUS_end)>1)
fprintf("on %s All Susceptible will be gone\n",SUS_end(1));
end

The value of any index if below 30 is displayed as the end of that case on the day of same index.

You might also like