function alf = alphamix(P,m,n) A = zeros(n-1); for j=1:n-1 P1j = getmargX(P,m,n,1:j); for k=1:n-j Pjk = getmargX(P,m,n,j+k:n); P1jkn = getmargX(P,m,n,[1:j,j+k:n]); dd = abs(tensprod1(P1j,Pjk)-P1jkn); A(j,k) = sum(dd)/2; end end alf = max(A); return function i=c2i(c,m,n) dims = repmat(m,[1 n]); i = coord2ind(c,dims); return function c=i2c(i,m,n) dims = repmat(m,[1 n]); c = ind2coord(i,dims); return