Home > gmmbayestb-v1.0 > gmmb_em_init_cmeans2.m

gmmb_em_init_cmeans2

PURPOSE ^

GMMB_EM_INIT_CMEANS2

SYNOPSIS ^

function initS = gmmb_em_init_cmeans2(data, C);

DESCRIPTION ^

 GMMB_EM_INIT_CMEANS2

 initS = gmmb_em_init_cmeans1(data, C)

 Create an initialization structure for EM,
 called from gmmb_em, see gmmb_em.

 C-means clustering means, cluster weight and covariance

 Author(s):
    Pekka Paalanen <pekka.paalanen@lut.fi>

 Copyright:

   Bayesian Classifier with Gaussian Mixture Model Pdf
   functionality is Copyright (C) 2004 by Pekka Paalanen and
   Joni-Kristian Kamarainen.

   $Name:  $ $Revision: 1.2 $  $Date: 2004/11/02 09:00:18 $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % GMMB_EM_INIT_CMEANS2
0002 %
0003 % initS = gmmb_em_init_cmeans1(data, C)
0004 %
0005 % Create an initialization structure for EM,
0006 % called from gmmb_em, see gmmb_em.
0007 %
0008 % C-means clustering means, cluster weight and covariance
0009 %
0010 % Author(s):
0011 %    Pekka Paalanen <pekka.paalanen@lut.fi>
0012 %
0013 % Copyright:
0014 %
0015 %   Bayesian Classifier with Gaussian Mixture Model Pdf
0016 %   functionality is Copyright (C) 2004 by Pekka Paalanen and
0017 %   Joni-Kristian Kamarainen.
0018 %
0019 %   $Name:  $ $Revision: 1.2 $  $Date: 2004/11/02 09:00:18 $
0020 
0021 
0022 function initS = gmmb_em_init_cmeans2(data, C);
0023 
0024 N = size(data,1);    % number of points
0025 D = size(data,2);    % dimensions
0026 
0027 if C>1
0028     [lbl, mu] = gmmb_cmeans(data, C, 15);
0029     % initialization has random nature, results will vary
0030 else
0031     lbl = ones(N, 1);
0032     mu = mean(data, 1);
0033 end
0034 
0035 % covariances initialization
0036 sigma = zeros(D,D,C);
0037 weight = ones(C,1);
0038 for c = 1:C
0039     sigma(:,:,c) = gmmb_covfixer(cov(data(lbl==c, :)));
0040     weight(c) = sum(lbl==c) / N;
0041 end
0042 
0043 initS = struct(...
0044     'mu', mu.', ...
0045     'sigma', sigma, ...
0046     'weight', weight ...
0047     );
0048

Generated on Thu 14-Apr-2005 13:50:22 by m2html © 2003