pt=c(0.1,0.1,0.8,0.2,0.3,0.5,0.4,0.3,0.3) dim(pt)=c(3,3) p=t(pt) steps=50 x=rep(1,steps+1) for (i in 2:steps+1) { r=runif(1);current=x[i-1] if (r