%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
Markov.m Script - computes the Markov Chains associated
% with probability of playing
successive
% Brownian games used to
illustate
% Parrondo's Paradox
%
% Author: Evan Shechtman
% Apr. 3, 2002
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
% Set
initial conditions
epsilon
= .001;
n =
2250;
modulus
= 3;
dollars
= 100;
win =
dollars+1;
% Set
transition matrices for Markov chain
for
x=1:win
for y=1:win
Ta(x,y)=0;
Tb(x,y)=0;
end
end
Ta(1,1)
= (1);
for
x=2:win-1
Ta(x-1,x) = (.5+epsilon);
Ta(x+1,x) = (.5-epsilon);
end
Ta(win,win)
= (1);
Tb(1,1)
= (1);
for
x=2:win-1
if (mod((x-1),modulus) == 0)
Tb(x-1,x) = (.9-epsilon);
Tb(x+1,x) = (.1+epsilon);
else
Tb(x-1,x) = (.25+epsilon);
Tb(x+1,x) = (.75-epsilon);
end
end
Tb(win,win)=(1);
% Set
state vectors
for
x=1:win
InitState(x)=0;
end
InitState(floor(win/2))=1;
%
Computing n successive moves starting
% at
each state
GameA =
Ta^n*InitState';
GameB =
Tb^n*InitState';
current
= InitState';
for
i=1:(floor(n/4))
current = Ta^2*current;
current = Tb^2*current;
end
% End
of markov()