%Functia de corelatie in tandem
pbr=0.01;%modelul tandem bernoulli
ptbr=2*pbr*(1-pbr);
tau=1:3000;
rtbr=ptbr*ones(1,3000);

p=0.187966*10^(-2);%modelul tandem gilbert-elliot
q=0.080617;
pg=0.563331*10^(-3);
pb=0.417201;
rtge=0.019855+0.193599*(0.89711.^tau)+0.00311722*(0.787395.^tau)+0.186951*(0.877698.^tau);

P=0.00278662; %modelul tandem bernoulli-gilbert
Q=0.119516;
Pg1=0.0105521;
Pb1=0.418857;
Zg=Q/P+Q;
Zb=P/P+Q;
ptbg=1.98;
rtbg=(Q*Pg1+P*Pb1)/(P+Q)+(P*Q*(Pb1-Pg1)^2)*((1-P-Q).^tau)/((P+Q)*(Q*Pg1+P*Pb1));

semilogx(tau,rtbr,'.y',tau,rtge,tau,rtbg)

title('Functia de corelatie a erorilor pentru modelele de canal tip tandem Bernoulli,tandem Gilbert-Elliot si tandem Bernoulli- Gilbert');
grid
xlabel('Factor de întretesere - tau');
ylabel('Functia de corelatie a erorilor R(tau)');
text(10,0.03,'TBR');
text(3,0.29,'TGE');
text(3,0.15,'TBG');

                