annotate mt_resample.m @ 18:062d46712995 tip

Moved mc_global_info1 back to public folder
author samer
date Mon, 02 Apr 2012 21:50:43 +0100
parents a6d5597bd922
children
rev   line source
samer@0 1 % mt_resample - Sample or resample melody triangle transition matrices of given size
samer@0 2 %
samer@0 3 % mt_resample ::
samer@0 4 % mt_system ~'initial system'
samer@0 5 % natural ~'size of transition matrices to resample'
samer@0 6 % -> action mt_system.
samer@0 7 %
samer@0 8 % A new set of transition matrices will be sampled and a 3D information space
samer@0 9 % scatter plot generated in the figure determined by the initial call to
samer@0 10 % mt_init.
samer@0 11
samer@0 12 function Sys=mt_resample(Sys,K)
samer@15 13 figure(Sys.fig+(K-1));
samer@11 14 cla;
samer@11 15
samer@11 16
samer@11 17 L=Sys.L;
samer@11 18 tol=Sys.tol;
samer@11 19 II=zeros(L,3);
samer@11 20 ok=zeros(1,L);
samer@11 21
samer@11 22 title(sprintf('sampling %d transition matrices...',L)); drawnow;
samer@11 23 TT=Sys.sample_transmats(K,L);
samer@11 24 title(sprintf('checking (tolerance=%f)...',tol)); drawnow;
samer@13 25 for i=1:L, [II(i,:),ok(i)]=mc_global_info1(TT(:,:,i),tol); end
samer@11 26 todo=find(~ok);
samer@11 27
samer@11 28 if Sys.ergmeth==1
samer@11 29 while ~isempty(todo)
samer@11 30 title(sprintf('resampling %d nonergodic transition matrices...',length(todo)));
samer@11 31 drawnow;
samer@11 32 TT(:,:,todo)=Sys.sample_transmats(K,length(todo));
samer@11 33 for i=todo, [II(i,:),ok(i)]=mc_global_info1(TT(:,:,i),tol); end
samer@11 34 todo=find(~ok);
samer@11 35 end
samer@11 36 else
samer@11 37 while ~isempty(todo)
samer@11 38 title(sprintf('perturbing %d nonergodic transition matrices...',length(todo)));
samer@11 39 drawnow;
samer@11 40 for i=todo, j=randnat(K); TT(:,j,i)=stoch(TT(:,j,i)+0.1); end
samer@11 41 for i=todo, [II(i,:),ok(i)]=mc_global_info1(TT(:,:,i),tol); end
samer@11 42 todo=find(~ok);
samer@11 43 end
samer@11 44 end
samer@11 45
samer@0 46 Sys.transmats{K} = TT;
samer@0 47 Sys.info{K} = II;
samer@11 48 Sys.hScat{K} = scatc(II/log(2),II(:,3)/log(2),16);
samer@0 49 axis on; box on; grid off;
samer@0 50 lc=[0.4,0.4,0.4];
samer@0 51 set(gca,'Color','none');
samer@0 52 set(gca,'XColor',lc);
samer@0 53 set(gca,'YColor',lc);
samer@0 54 set(gca,'ZColor',lc);
samer@0 55 xlabel('entropy rate');
samer@0 56 ylabel('redundancy');
samer@0 57 zlabel('pred-info rate');
samer@0 58 rotate3d on;
samer@0 59 end
samer@11 60
samer@11 61
samer@11 62
samer@11 63