Institut de Robòtica i Informàtica Industrial

GMixture

PURPOSE ^

Gaussian mixture constructor.

SYNOPSIS ^

function gm=GMixture(varargin)

DESCRIPTION ^

   Gaussian mixture constructor.

   Defines a (non-necessarily normalized) Gaussian mixture given the
   weights and the Gaussian  for each component.
   Possible parameters
     - None: Defines an empty Gaussian mixture.
     - Another Gaussian mixture: Copy constructor.
     - w,g: The (row) vector of weigths and a cell array of Gaussians.
     - g: The cell array of Gaussians. In this case the weights are
          assumed uniform.

CROSS-REFERENCE INFORMATION ^

This function calls:
  • size Returns the size of a policy.
  • GMixture Gaussian mixture constructor.
This function is called by:

SOURCE CODE ^

0001 function gm=GMixture(varargin)
0002 %   Gaussian mixture constructor.
0003 %
0004 %   Defines a (non-necessarily normalized) Gaussian mixture given the
0005 %   weights and the Gaussian  for each component.
0006 %   Possible parameters
0007 %     - None: Defines an empty Gaussian mixture.
0008 %     - Another Gaussian mixture: Copy constructor.
0009 %     - w,g: The (row) vector of weigths and a cell array of Gaussians.
0010 %     - g: The cell array of Gaussians. In this case the weights are
0011 %          assumed uniform.
0012 
0013   switch nargin
0014     case 0
0015       gm.w=[];
0016       gm.g={};
0017       gm.n=0;
0018       gm=class(gm,'GMixture');
0019     case 1
0020       if isa(varargin{1},'GMixture')
0021         gm=varargin{1};
0022       else
0023         if isa(varargin{1},'cell')
0024           n=size(varargin{1},2);
0025           gm=GMixture(ones(1,n)/n,varargin{1});
0026         else
0027           error('Wrong type of parameters in GMixture constructor');
0028         end
0029       end
0030     case 2
0031       n1=size(varargin{1},2);
0032       n2=size(varargin{2},2);
0033       if n1~=n2
0034         error('Size missmatch in GMixture constructor');
0035       end
0036       if isa(varargin{1},'double')
0037         gm.w=varargin{1};
0038       else
0039         error('Wrong type of parameters in GMixture constructor');
0040       end
0041       if isa(varargin{2},'cell')
0042         gm.g=varargin{2};
0043       else
0044         error('Wrong type of parameters in GMixture constructor');
0045       end
0046       gm.n=n1;
0047       gm=class(gm,'GMixture');
0048     otherwise
0049       error('Wrong number of parameters in GMixture constructor');
0050   end


Institut de Robòtica i Informàtica Industrial

Generated on Wed 05-Aug-2009 15:05:21 by m2html © 2003