samer@0: % mt_resample - Sample or resample melody triangle transition matrices of given size samer@0: % samer@0: % mt_resample :: samer@0: % mt_system ~'initial system' samer@0: % natural ~'size of transition matrices to resample' samer@0: % -> action mt_system. samer@0: % samer@0: % A new set of transition matrices will be sampled and a 3D information space samer@0: % scatter plot generated in the figure determined by the initial call to samer@0: % mt_init. samer@0: samer@0: function Sys=mt_resample(Sys,K) samer@15: figure(Sys.fig+(K-1)); samer@11: cla; samer@11: samer@11: samer@11: L=Sys.L; samer@11: tol=Sys.tol; samer@11: II=zeros(L,3); samer@11: ok=zeros(1,L); samer@11: samer@11: title(sprintf('sampling %d transition matrices...',L)); drawnow; samer@11: TT=Sys.sample_transmats(K,L); samer@11: title(sprintf('checking (tolerance=%f)...',tol)); drawnow; samer@13: for i=1:L, [II(i,:),ok(i)]=mc_global_info1(TT(:,:,i),tol); end samer@11: todo=find(~ok); samer@11: samer@11: if Sys.ergmeth==1 samer@11: while ~isempty(todo) samer@11: title(sprintf('resampling %d nonergodic transition matrices...',length(todo))); samer@11: drawnow; samer@11: TT(:,:,todo)=Sys.sample_transmats(K,length(todo)); samer@11: for i=todo, [II(i,:),ok(i)]=mc_global_info1(TT(:,:,i),tol); end samer@11: todo=find(~ok); samer@11: end samer@11: else samer@11: while ~isempty(todo) samer@11: title(sprintf('perturbing %d nonergodic transition matrices...',length(todo))); samer@11: drawnow; samer@11: for i=todo, j=randnat(K); TT(:,j,i)=stoch(TT(:,j,i)+0.1); end samer@11: for i=todo, [II(i,:),ok(i)]=mc_global_info1(TT(:,:,i),tol); end samer@11: todo=find(~ok); samer@11: end samer@11: end samer@11: samer@0: Sys.transmats{K} = TT; samer@0: Sys.info{K} = II; samer@11: Sys.hScat{K} = scatc(II/log(2),II(:,3)/log(2),16); samer@0: axis on; box on; grid off; samer@0: lc=[0.4,0.4,0.4]; samer@0: set(gca,'Color','none'); samer@0: set(gca,'XColor',lc); samer@0: set(gca,'YColor',lc); samer@0: set(gca,'ZColor',lc); samer@0: xlabel('entropy rate'); samer@0: ylabel('redundancy'); samer@0: zlabel('pred-info rate'); samer@0: rotate3d on; samer@0: end samer@11: samer@11: samer@11: samer@11: