Professional Documents
Culture Documents
OLEH:
NAMA : SATRIANI
NIM : F1A116058
JURUSAN MATEMATIKA
KENDARI
2019
Pengenalan Model Epidemik Stokastik
1. Program
% MatLab Program # 1
% Discrete Time Markov Chain
% SIS Epidemic Model
% Transition Matrix and Graph of Probability Distribution
clear all
set(gca,'FontSize',18);
set(0,'DefaultAxesFontSize',18);
time=2000;
dtt=0.01; % Time step
beta=1*dtt;
b=0.25*dtt;
gama=0.25*dtt;
N=100; % Total population size
en=50; % plot every enth time interval
T=zeros(N+1,N+1); % T is the transition matrix, defined
below
v=linspace(0,N,N+1);
p=zeros(time+1,N+1);
p(1,3)=1; % Two individuals initially infected.
bt=beta*v.*(N-v)/N;
dt=(b+gama)*v;
fori=2:N % Define the transition matrix
T(i,i)=1-bt(i)-dt(i); % diagonal entries
T(i,i+1)=dt(i+1); % superdiagonal entries
T(i+1,i)=bt(i); % subdiagonal entries
end
T(1,1)=1;
T(1,2)=dt(2);
T(N+1,N+1)=1-dt(N+1);
for t=1:time
y=T*p(t,:)';
p(t+1,:)=y';
end
pm(1,:)=p(1,:);
for t=1:time/en;
pm(t+1,:)=p(en*t,:);
end
ti=linspace(0,time,time/en+1);
st=linspace(0,N,N+1);
mesh(st,ti,pm);
xlabel('Number of Infectives');
ylabel('Time Steps');
zlabel('Probability');
view(140,30);
axis([0,N,0,time,0,1]);
Hasil Run program
2. Program
% Matlab Program # 2
% Continuous Time Markov Chain
% SIS Epidemic Model
% Three Sample Paths and the Deterministic Solution
clear
set(0,'DefaultAxesFontSize', 18);
set(gca,'fontsize',18);
beta=1;
b=0.25;
gam=0.25;
N=100;
init=2;
time=25;
sim=3;
for k=1:sim
clear tsi
t(1)=0;
i(1)=init;
s(1)=N-init;
j=1;
whilei(j)>0 && t(j)<time
u1=rand; % uniform random number
u2=rand; % uniform random number
a=(beta/N)*i(j)*s(j)+(b+gam)*i(j);
probi=(beta*s(j)/N)/(beta*s(j)/N+b+gam);
t(j+1)=t(j)-log(u1)/a;
if u2 <= probi
i(j+1)=i(j)+1;
s(j+1)=s(j)-1;
else
i(j+1)=i(j)-1;
s(j+1)=s(j)+1;
end
j=j+1;
end
plot(t,i,'r-','LineWidth',2)
hold on
end
Hasil run program
3. Program
% Matlab Program # 3
% Stochastic Differential Equation
% SIS Epidemic Model
% Three Sample Paths and the Deterministic Solution
clear
beta=1;
b=0.25;
gam=0.25;
N=100;
init=2;
dt=0.01;
time=25;
sim=3;
for k=1:sim
j=1;
i(j)=init;
t(j)=dt;
whilei(j)>0 & t(j)<25
mu=beta*i(j)*(N-i(j))/N-(b+gam)*i(j);
sigma=sqrt(beta*i(j)*(N-i(j))/N+(b+gam)*i(j));
rn=randn; % standard normal random number
i(j+1)=i(j)+mu*dt+sigma*sqrt(dt)*rn;
t(j+1)=t(j)+dt;
j=j+1;
end
plot(t,i,'r-','Linewidth',2);
hold on
end
% Euler’s method applied to the deterministic SIS model.
y(1)=init;
for k=1:time/dt
y(k+1)=y(k)+dt*(beta*(N-y(k))*y(k)/N-(b+gam)*y(k));
end
plot([0:dt:time],y,'k--','LineWidth',2);
axis([0,time,0,80]);
xlabel('Time');
ylabel('Number of Infectives');
hold off
Hasil run program
Kajian Model Deterministik dan Stokastik Waktu Kontinu pada Model
Epidemik SIS
1. Program sample path individu rentan dan terinfeksi saat 𝑅0 = 0,2
set(0,'DefaultAxesFontSize',10);
set(gca,'fontsize',10);
beta=0.1;
b=0.2;
gam=0.3;
N=100;
init=12;
time=150;
sim=2;
for k=1:sim
clear t s i
t(1)=0;
i(1)=init;
s(1)=N-init;
j=1;
while i(j)>0 & t(j)<time
u1=rand;
u2=rand;
a=(beta/N)*i(j)*s(j)+(b+gam)*i(j);
probi=(beta*s(j)/N)/(beta*s(j)/N+b+gam);
t(j+1)=t(j)-log(u1)/a;
if u2 <= probi
i(j+1)=i(j)+1;
s(j+1)=s(j)-1;
else
i(j+1)=i(j)-1;
s(j+1)=s(j)+1;
end
j=j+1;
end
plot(t,i,'r-','LineWidth',2)
plot(t,s,'b-','LineWidth',2)
hold on
end
xlabel('Time');
ylabel('Individuals');
function SIR_02(S0,I0,R0,a,d,lambda,beta,m,alpha1,
alpha2,k1,tmax)
S=zeros(1,tmax);
I=zeros(1,tmax);
R=zeros(1,tmax);
S(1)=S0;
I(1)=I0;
R(1)=R0;
T(1)=0;
for t=1:1:tmax
T(t+1)=t;
S(t+1)=S(t)+(a-d*S(t)-
(lambda*S(t)*I(t)/(1+alpha1*I(t)+alpha2*I(t)^2))+beta*R(t));
I(t+1)=I(t)+((lambda*S(t)*I(t)/(1+alpha1*I(t)+alpha2*I(t)^2)
)-(d+m+k1)*I(t));
R(t+1)=R(t)+(m*I(t)-(d+beta)*R(t)+k1*I(t));
end
plot(T,S,T,I,T,R);
title('SIR Model');
legend('S(t)','I(t)','R(t)');
xlabel('time, t');
ylabel('Population');
functiondy=predatorprey(t,x)
global a k c b j n v l e h q m p;
dy=zeros(4,1);
dy(1) = a*x(1)*(1-((x(1)+x(2))/k))-c*x(3)*x(1)-
b*x(1)*x(2)+j*x(2);
dy(2) = b*x(2)*x(1)-n*x(2)*x(3)-j*x(2)-v*x(2);
dy(3) = -l*x(3)+e*x(1)*x(3)-h*x(3)*x(4)+q*x(2)*x(3);
dy(4) = -m*x(4)+p*x(3)*x(4)
end
functiondy=predatorprey(t,x)
global a k c b j n v l e h q m p;
dy=zeros(4,1);
dy(1) = a*x(1)*(1-((x(1)+x(2))/k))-c*x(3)*x(1)-b*x(1)*x(2)+j*x(2);
dy(2) = b*x(2)*x(1)-n*x(2)*x(3)-j*x(2)-v*x(2);
dy(3) = -l*x(3)+e*x(1)*x(3)-h*x(3)*x(4)+q*x(2)*x(3);
dy(4) = -m*x(4)+p*x(3)*x(4)
end
b. Membuat M-file baru untuk memplot fungsi predatorprey.m sebagai berikut
disp('simulasi model
matematikarantaimakanantigatingkatdenganadanyamangsaterinf
eksisaatkepunahan top predator');
global a k c b j n v l e h q m p;
a = 0.8;
k = 150;
c = 0.3;
b = 0.75;
j = 0.95;
n = 0.95;
v = 0.009;
l = 0.1;
e = 0.1;
h = 0.4;
q = 0.1;
m = 0.75;
p = 0.1;
[t1,x1] = ode45(@predatorprey, [0 150], [35 30 20 15]);
figure(1);
plot(t1,x1(:,1),'g',t1,x1(:,2),'b',t1,x1(:,3),'r',t1,x1(:,
4),'c');
legend('mangsarentan (S)','mangsaterinfeksi
(I)','intermediet (V)','top predator (W)');
xlabel('waktu (t)');
ylabel('jumlahpopulasi');
grid on;
functiondy=predatorprey(t,x)
global a k c b j n v l e h q m p;
dy=zeros(4,1);
dy(1) = a*x(1)*(1-((x(1)+x(2))/k))-c*x(3)*x(1)-b*x(1)*x(2)+j*x(2);
dy(2) = b*x(2)*x(1)-n*x(2)*x(3)-j*x(2)-v*x(2);
dy(3) = -l*x(3)+e*x(1)*x(3)-h*x(3)*x(4)+q*x(2)*x(3);
dy(4) = -m*x(4)+p*x(3)*x(4)
end
b. Membuat M-file baru untuk memplot fungsi predatorprey.m sebagai berikut
disp('simulasi model
matematikarantaimakanantigatingkatdenganadanyamangsaterinf
eksisaatkondisikepunahanintermeiet,preyterinfeksi,dan top
predator');
global a k c b j n v l e h q m p;
a = 0.15;
k = 150;
c = 0.01;
b = 0.005;
j = 0.75;
n = 0.15;
v = 0.85;
l = 0.45;
e = 0.002;
h = 0.1;
q = 0.01;
m = 0.2;
p = 0.08;
[t1,x1] = ode45(@predatorprey, [0 150], [35 30 20 15]);
figure(1);
plot(t1,x1(:,1),'g',t1,x1(:,2),'b',t1,x1(:,3),'r',t1,x1(:,
4),'c');
legend('mangsarentan (S)','mangsaterinfeksi
(I)','intermediet (V)','top predator (W)');
xlabel('waktu (t)');
ylabel('jumlahpopulasi');
grid on;
I(i+1)=I(i)+(beta*S(i)*Z(i)*deltaT)+(beta*S(i)*I(i)*deltaT)-
(mu*I(i)*deltaT)-(deltah*I(i)*deltaT)-(gammah*I(i)*deltaT)-
(alpha*I(i)*deltaT);
R(i+1)=Y(i)+(gammah*I(i)*deltaT)-(mu*R(i)*deltaT)-
(lamda*R(i)*deltaT);
Y(i+1)=Y(i)+(bdua*deltaT)-(gammav*Y(i)*deltaT)-
(beta*Y(i)*I(1)*deltaT);
Z(i+1)=Z(i)+(beta*Y(i)*I(1)*deltaT)-
(gammav*Z(i)*deltaT)-(deltav*Z(i)*deltaT);
t(i+1)=t(i)+deltaT;
i=i+1;
end
%numerisasi model
disp('***************************************');
disp('Model Penyebaran Penyakit Leptospirosis');
disp('***************************************');
disp('waktu(t) Y(t) Z(t) R(t)');
disp([(t(m))' (Y(m))' (Z(m))' (R(m))']);
%plot grafik
plot(t,S, 'g', 'lineWidth' ,2);
hold on; plot(t,I, 'r' , 'lineWidth' ,2);
hold on; plot(t,R, 'b' , 'lineWidth' ,2);
title('Model SIR Penyebaran Penyakit Leptospirosis Pada
Manusia');
xlabel('waktu(t) dalam tahun');
ylabel('populasi S, I, dan R');
legend('Y=Susceptibles','Z=Infected', 'R=Recovery');
grid on
Hasil run program