CompressGRPURPOSEGaussian mixture compression using the Golberger and Roweis method.
SYNOPSISfunction [gmC map]=CompressGR(gm,m,epsilon,MaxIterations)
DESCRIPTIONGaussian mixture compression using the Golberger and Roweis method. Compresses a normalized Gaussian mixture so that it includes at most 'm' elements. This function implements the method by Golberger and Roweis described in appendix A of the paper. Parameters gm: The normalized mixture to compress m: The maximum number of components in the output compressed normalized mixture. epsilon: Convergence criterion. If the relative error between two iterations changes less than epsilon we stop the process. MaxIterations: If the process iterates more times than this threshold the compression process is stopped. Output: gmC: The output normalized mixture. map: Map between components in the input mixtures and those in the output one (This in \pi in Table 3 in Appendix A in the paper). CROSS-REFERENCE INFORMATIONThis function calls:
SOURCE CODE0001 function [gmC map]=CompressGR(gm,m,epsilon,MaxIterations) 0002 % Gaussian mixture compression using the Golberger and Roweis method. 0003 % 0004 % Compresses a normalized Gaussian mixture so that it includes at most 0005 % 'm' elements. 0006 % This function implements the method by Golberger and Roweis described 0007 % in appendix A of the paper. 0008 % 0009 % Parameters 0010 % gm: The normalized mixture to compress 0011 % m: The maximum number of components in the output compressed 0012 % normalized mixture. 0013 % epsilon: Convergence criterion. If the relative error between two 0014 % iterations changes less than epsilon we stop the process. 0015 % MaxIterations: If the process iterates more times than this threshold 0016 % the compression process is stopped. 0017 % Output: 0018 % gmC: The output normalized mixture. 0019 % map: Map between components in the input mixtures and those in the 0020 % output one (This in \pi in Table 3 in Appendix A in the paper). 0021 0022 if (gm.n<=m) 0023 % 'gm' is already compressed 0024 gmC=gm; 0025 map=1:gm.n; %trivial mapping one to one 0026 else 0027 0028 gmC=GetLargestComponents(gm,m); 0029 % gmC=GetRandomComponents(gm,m); 0030 % gmC=GetFirstComponents(gm,m); 0031 0032 % default fake distance 0033 d=inf; 0034 0035 % default mapping (just to allocate space) 0036 map=1:gm.n; 0037 0038 iteration=1; 0039 stop=false; 0040 while ~stop 0041 0042 %Compute the mapping from 'gm' to 'gmC 0043 for i=1:gm.n 0044 f=gm.g{i}; 0045 [md map(i)]=min(cellfun(@(g)GaussianKL(f,g),gmC.g)); 0046 end 0047 0048 %Update 'gmC' 0049 for j=1:m 0050 % get the components of gm that are close to the j component of gmC 0051 ndx=(map==j); 0052 sw=sum(gm.w(ndx)); 0053 if sw>0 0054 gmC.w(j)=sw; 0055 gmC.g{j}=FuseComponents(GMixture(gm.w(ndx)/sw,gm.g(ndx))); 0056 else 0057 % None of the components of gm is close to this component of gmC 0058 % Replace with one random component from gm 0059 m1=ceil(rand*gm.n); 0060 gmC.w(j)=gm.w(m1); 0061 gmC.g{j}=gm.g{m1}; 0062 end 0063 end 0064 gmC=Normalize(gmC); 0065 0066 % Update the distance from 'gmC' to 'gm' 0067 d1=d; 0068 d=cellfun(@(f,g)(GaussianKL(f,g)),gm.g,gmC.g(map))*gm.w'; 0069 0070 iteration=iteration+1; 0071 0072 stop=((d<epsilon)||(abs(d1-d)/d<epsilon)); 0073 0074 if (~stop) 0075 if (d1<d) 0076 error('Increasing distance'); 0077 end 0078 if (iteration>MaxIterations) 0079 error('Too slow convergence'); 0080 end 0081 end 0082 end 0083 0084 end |