comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [mu, Sigma] = mixgaussTrainObserved(obsData, hiddenData, nstates, varargin);
2 % mixgaussTrainObserved Max likelihood estimates of conditional Gaussian from raw data
3 % function [mu, Sigma] = mixgaussTrainObserved(obsData, hiddenData, nstates, ...);
4 %
5 % Input:
6 % obsData(:,i)
7 % hiddenData(i) - this is the mixture component label for example i
8 % Optional arguments - same as mixgauss_Mstep
9 %
10 % Output:
11 % mu(:,q)
12 % Sigma(:,:,q) - same as mixgauss_Mstep
13
14 [D numex] = size(obsData);
15 Y = zeros(D, nstates);
16 YY = zeros(D,D,nstates);
17 YTY = zeros(nstates,1);
18 w = zeros(nstates, 1);
19 for q=1:nstates
20 ndx = find(hiddenData==q);
21 w(q) = length(ndx); % each data point has probability 1 of being in this cluster
22 data = obsData(:,ndx);
23 Y(:,q) = sum(data,2);
24 YY(:,:,q) = data*data';
25 YTY(q) = sum(diag(data'*data));
26 end
27 [mu, Sigma] = mixgauss_Mstep(w, Y, YY, YTY, varargin{:});