CompressGR
PURPOSE 
Gaussian mixture compression using the Golberger and Roweis method.
SYNOPSIS 
function [gmC map]=CompressGR(gm,m,epsilon,MaxIterations)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- rand Random state from a discrete belief.
- rand Random state from a belief.
- FuseComponents Fuses a Gaussian mixture into a single Gaussian.
- GMixture Gaussian mixture constructor.
- GetLargestComponents Gets the components with the largest weigth.
- Normalize Normalize a GMixture.
- rand Generates random points on a GMixture.
- GaussianKL Gaussian Kullback-Leibler distance.
- rand Generates random ponts on a Gaussian.
- min Lower bound of a CSpace
- rand Random state from a continuous space.
- rand Random state from a discrete space.
This function is called by:
SOURCE CODE 
0001 function [gmC map]=CompressGR(gm,m,epsilon,MaxIterations)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if (gm.n<=m)
0023
0024 gmC=gm;
0025 map=1:gm.n;
0026 else
0027
0028 gmC=GetLargestComponents(gm,m);
0029
0030
0031
0032
0033 d=inf;
0034
0035
0036 map=1:gm.n;
0037
0038 iteration=1;
0039 stop=false;
0040 while ~stop
0041
0042
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
0049 for j=1:m
0050
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
0058
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
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
|