annotate toolboxes/FullBNT-1.0.7/KPMstats/condgaussTrainObserved.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [mu, Sigma] = mixgaussTrainObserved(obsData, hiddenData, nstates, varargin);
wolffd@0 2 % mixgaussTrainObserved Max likelihood estimates of conditional Gaussian from raw data
wolffd@0 3 % function [mu, Sigma] = mixgaussTrainObserved(obsData, hiddenData, nstates, ...);
wolffd@0 4 %
wolffd@0 5 % Input:
wolffd@0 6 % obsData(:,i)
wolffd@0 7 % hiddenData(i) - this is the mixture component label for example i
wolffd@0 8 % Optional arguments - same as mixgauss_Mstep
wolffd@0 9 %
wolffd@0 10 % Output:
wolffd@0 11 % mu(:,q)
wolffd@0 12 % Sigma(:,:,q) - same as mixgauss_Mstep
wolffd@0 13
wolffd@0 14 [D numex] = size(obsData);
wolffd@0 15 Y = zeros(D, nstates);
wolffd@0 16 YY = zeros(D,D,nstates);
wolffd@0 17 YTY = zeros(nstates,1);
wolffd@0 18 w = zeros(nstates, 1);
wolffd@0 19 for q=1:nstates
wolffd@0 20 ndx = find(hiddenData==q);
wolffd@0 21 w(q) = length(ndx); % each data point has probability 1 of being in this cluster
wolffd@0 22 data = obsData(:,ndx);
wolffd@0 23 Y(:,q) = sum(data,2);
wolffd@0 24 YY(:,:,q) = data*data';
wolffd@0 25 YTY(q) = sum(diag(data'*data));
wolffd@0 26 end
wolffd@0 27 [mu, Sigma] = mixgauss_Mstep(w, Y, YY, YTY, varargin{:});