function [A,C] = markov_approx(P,m,n) A = pnormdim(ones(m,m,n-1),1); C = pnormdim(ones(m,1, 1),1); for t=2:n prefdim = repmat([m],[1 t-1]); for shrt = 1:m pshrt = getPX(P,m,n,shrt, t-1) + realmin; for Xt = 1:m pjshrt = getPX(P,m,n,[shrt Xt],t-1:t); part = pjshrt / pshrt; A(Xt,shrt,t-1) = part; end end end % compute the initial prob C for x1 = 1:m C(x1) = getPX(P,m,n,x1,1); end return