
clear
N=100;
rho = 0.05;

x(1) = rand(1)<0.5;
for i=2:N
  change = rand(1)<rho;
  if(change) 
    x(i) = ~x(i-1);
  else 
    x(i) = x(i-1);
  end
end

plot(x)
axis([1 N -0.5 1.5]);
S = sprintf('Binary Valued Markov Chain: rho = %f',rho);
title(S)
xlabel('discrete time, n')
ylabel('yaxis')

print dchain1.eps -epsi




rho = 0.2;

x(1) = rand(1)<0.5;
for i=2:N
  change = rand(1)<rho;
  if(change) 
    x(i) = ~x(i-1);
  else 
    x(i) = x(i-1);
  end
end

plot(x)
axis([1 N -0.5 1.5]);
S = sprintf('Binary Valued Markov Chain: rho = %f',rho);
title(S)
xlabel('discrete time, n')
ylabel('yaxis')

print dchain2.eps -epsi
