clear all
P = [0,1/3,2/3;1/3,0,2/3;1,0,0];
v = [zeros(1,3),1]/[P-eye(3),ones(3,1)]
v*[20;30;40]
N = 1000;
f = zeros(1,3);
i = 1;
f(i) = f(i)+1;
g = 20;
for n = 2:N
    i = randdisc(P(i,:));
    f(i) = f(i)+1;
    g = g+(i+1)*10;
end
f/N
g/N