function mequiv3 global m n = 3; m = 3; global A C XX PPM A = pnormdim(rand(m,m),1) C = pnormdim(rand(m,1),1) dims = repmat([2],[1 n]); XX = list_all_ind(dims)-1; nx = size(XX,1); PPM = zeros(nx,1); PROGstart(nx,'computing collapsed probs...'); for j=1:nx X = XX(j,:); Pm = PM(X,A,C); PPM(j) = Pm; PROGupdate(j); end PROGend; return function x=hinv(y) global m if y==0 x = 0; else x = 1:m-1; end return function XX=HINV(Y) x={}; for i=1:length(Y) x{i} = hinv(Y(i)); end XX = list_all_ind_g(x); return function p = PM(Y,A,C) XX = HINV(Y); p = 0; [N,n] = size(XX); for j=1:N X = XX(j,:); p = p + P(X,A,C); end return function p = P(x,A,C) x=x+1; if isempty(x) p = 1; else p = C(x(1)); end for j=2:length(x) p = p * A(x(j),x(j-1)); % markov case end return function [A,C] = collapse(A,C,th) %th = rand; % mixing coeff [n,n] = size(A); % collapse states n-1 and n A(n-1,:) = A(n-1,:) + A(n,:); A(:,n-1) = th*A(:,n-1) + (1-th)*A(:,n); A = A(1:n-1,1:n-1); C(n-1) = C(n-1) + C(n); C=C(1:n-1); return function h = strict(A) [n,n] = size(A); d = 0; for i=1:n for j=i+1:n x = A(:,i); y = A(:,j); d = max(d,.5*sum(abs(x-y))); % this stricture has the VERY NICE property % of not increasing after state collapse %d = max(d,max(abs(x-y))); % this is the OLD, BAD stricture def. % that's the problem that Sinai was so quick to point out % in my terminology, this stricture might increase after collapse end end h=d; return function b=compallpairs(A,B) global n [n,n] = size(A); b = 1; for i=1:n for j=i+1:n for k=1:n a1 = A(k,i); a2 = A(k,j); da = abs(a1-a2); b1 = B(ci(k),ci(i)); b2 = B(ci(k),ci(j)); db = abs(b1-b2); b = b & (db <= da); end end end return function i = ci(i) global n if i==n i=n-1; end return