Mercurial > hg > camir-aes2014
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolboxes/FullBNT-1.0.7/KPMstats/condgaussTrainObserved.m Tue Feb 10 15:05:51 2015 +0000 @@ -0,0 +1,27 @@ +function [mu, Sigma] = mixgaussTrainObserved(obsData, hiddenData, nstates, varargin); +% mixgaussTrainObserved Max likelihood estimates of conditional Gaussian from raw data +% function [mu, Sigma] = mixgaussTrainObserved(obsData, hiddenData, nstates, ...); +% +% Input: +% obsData(:,i) +% hiddenData(i) - this is the mixture component label for example i +% Optional arguments - same as mixgauss_Mstep +% +% Output: +% mu(:,q) +% Sigma(:,:,q) - same as mixgauss_Mstep + +[D numex] = size(obsData); +Y = zeros(D, nstates); +YY = zeros(D,D,nstates); +YTY = zeros(nstates,1); +w = zeros(nstates, 1); +for q=1:nstates + ndx = find(hiddenData==q); + w(q) = length(ndx); % each data point has probability 1 of being in this cluster + data = obsData(:,ndx); + Y(:,q) = sum(data,2); + YY(:,:,q) = data*data'; + YTY(q) = sum(diag(data'*data)); +end +[mu, Sigma] = mixgauss_Mstep(w, Y, YY, YTY, varargin{:});