function phylosketch(m0,n0) global m n randomize m = m0; n = n0; global pstr pstr = mfilename global lstr rstr global maxr maxr = 0; global A C T P Pleaf leafs ll while 1 %T = randdtree(n); T=zeros(n); T(1,2:n)=ones(1,n-1); %T = bintree(2); %n = size(T,1); [nodesi,nodesj]=find(T); A=[]; A0 = pnormdim(rand(m,m),1); tha = strict(A0); for e=1:length(nodesi) e1 = nodesi(e); e2 = nodesj(e); Ae = pnormdim(rand(m,m),1); Ae = reshape(Ae,1,1,m,m); A(e1,e2,:,:) = Ae; %A(e1,e2,:,:) = A0; end C = pnormdim(rand(m,1),1); P = dtreefillprob1(m,n,T,A,C); [hh0,Ht,H] = gethhn(P,m,n); leafs = leaves(T); [w,levels,ll] = treewidth(T); Pleaf = getmargX(P,m,n,leafs); [hh,Ht,H] = gethhn(Pleaf,m,length(leafs)); ll = length(leafs); for i=1:ll for j=i+1:ll %checketaij(i,j) iL = leafs(i); jL = leafs(j); hub = dtreehijub(A,C,T,m,n,iL,jL); hij = hh(i,j); %thij = tha^(j-i); global thij %thij = (1-(1-tha)^w)^floor((j-i)/w); r = hij/hub; %r = hij/thij; %r = hij/h0ij; if r>2,keyboard,end maxr = max(r,maxr); end end fprintf('%s: PARAMS: n=%d m=%d \n',pstr,n,m); fprintf('RATIO_________________________ maxr = %1.9f \n',maxr); end return function checketaij(i,j) global A C T P Pleaf leafs ll m n leafs = leafs(:)'; for yi=1:m^(i-1) y = i2c(yi,m,i-1); for w0 = 1:m for w1 = w0+1:m checketayw(i,j,y,w0,w1); end end end return function checketayw(i,j,y,w0,w1) global A C T P Pleaf leafs ll m n P0 = getcondP(Pleaf,m,ll,[j:ll],[1:i],[y w0]); P1 = getcondP(Pleaf,m,ll,[j:ll],[1:i],[y w1]); h0 = .5*sum(abs(P0-P1)); Int = setdiff(1:n,leafs); nI = length(Int); xsum = 0; for xi=1:m^(ll-j+1) x = i2c(xi,m,ll-j+1); zsum = 0; for zi=1:m^(j-i-1) z = i2c(zi,m,j-i-1); for shi = 1:m^nI sh = i2c(shi,m,nI); psh = mu(sh,Int); pco = muc([y z x],leafs([1:i-1,i+1:ll]),sh,Int); f0 = muc(w0,leafs(i),sh,Int)/rho([y w0],1:i); f1 = muc(w1,leafs(i),sh,Int)/rho([y w1],1:i); zsum = zsum + psh * pco * (f0 - f1); end end xsum = xsum + abs(zsum); end h1 = xsum/2; good = (abs(h0-h1)<1e-9); if ~good 'bad1' keyboard end xsum = 0; for xi=1:m^(ll-j+1) x = i2c(xi,m,ll-j+1); for shi = 1:m^nI sh = i2c(shi,m,nI); psh = mu(sh,Int); zsum = 0; for zi=1:m^(j-i-1) z = i2c(zi,m,j-i-1); pco = muc([y z x],leafs([1:i-1,i+1:ll]),sh,Int); f0 = muc(w0,leafs(i),sh,Int)/rho([y w0],1:i); f1 = muc(w1,leafs(i),sh,Int)/rho([y w1],1:i); zsum = zsum + pco * (f0 - f1); end xsum = xsum + psh*abs(zsum); end end h2 = xsum/2; good = (h1+1e-9