若当前状态为A生成第一个随机数(范围0.00-1.00)
case 0-0.01: Result = 0;
0.01-1.00: Result = 1;
然后生成第二个随机数(范围0.00-1.00)
if 0-0.005 状态转移为B;
else 状态不变;
若当前状态为B
生成第一个随机数(范围0.00-1.00)
case 0-0.90: Result = 0;
0.90-1.00: Result = 1;
然后生成第二个随机数(范围0.00-1.00)
if 0-0.027 状态转移为A;
else 状态不变;
code:
np=rand(1,2) ;
N = N + 1;
if status == 1 %Good Network
if np(1) < Pod(1)
%data lost
Output = 0;
else
Output = 1;
end
if np(2) < Pot(1) %|| ( t>14 && t<15) %transition to Bad
status = 0;
end
else %Bad Network
if np(1) < Pod(2) %|| ( t>14 && t<15) )
%data lost
Output = 0;
else
Output = 1;
end
if np(2) < Pot(2) || (PP/N) > P %|| ( t<14 && t>15) %transition to good
status = 1;
end
end