wolffd@0: function [initState, transmat, mu, Sigma] = gausshmm_train_observed(obsData, hiddenData, ... wolffd@0: nstates, varargin) wolffd@0: % GAUSSHMM_TRAIN_OBSERVED Estimate params of HMM with Gaussian output from fully observed sequences wolffd@0: % [initState, transmat, mu, Sigma] = gausshmm_train_observed(obsData, hiddenData, nstates,...) wolffd@0: % wolffd@0: % INPUT wolffd@0: % If all sequences have the same length wolffd@0: % obsData(:,t,ex) wolffd@0: % hiddenData(ex,t) - must be ROW vector if only one sequence wolffd@0: % If sequences have different lengths, we use cell arrays wolffd@0: % obsData{ex}(:,t) wolffd@0: % hiddenData{ex}(t) wolffd@0: % wolffd@0: % Optional argumnets wolffd@0: % dirichletPriorWeight - for smoothing transition matrix counts wolffd@0: % wolffd@0: % Optional parameters from mixgauss_Mstep: wolffd@0: % 'cov_type' - 'full', 'diag' or 'spherical' ['full'] wolffd@0: % 'tied_cov' - 1 (Sigma) or 0 (Sigma_i) [0] wolffd@0: % 'clamped_cov' - pass in clamped value, or [] if unclamped [ [] ] wolffd@0: % 'clamped_mean' - pass in clamped value, or [] if unclamped [ [] ] wolffd@0: % 'cov_prior' - Lambda_i, added to YY(:,:,i) [0.01*eye(d,d,Q)] wolffd@0: % wolffd@0: % Output wolffd@0: % mu(:,q) wolffd@0: % Sigma(:,:,q) wolffd@0: wolffd@0: [dirichletPriorWeight, other] = process_options(... wolffd@0: varargin, 'dirichletPriorWeight', 0); wolffd@0: wolffd@0: [transmat, initState] = transmat_train_observed(hiddenData, nstates, ... wolffd@0: 'dirichletPriorWeight', dirichletPriorWeight); wolffd@0: wolffd@0: % convert to obsData(:,t*nex) wolffd@0: if ~iscell(obsData) wolffd@0: [D T Nex] = size(obsData); wolffd@0: obsData = reshape(obsData, D, T*Nex); wolffd@0: else wolffd@0: obsData = cat(2, obsData{:}); wolffd@0: hiddenData = cat(2,hiddenData{:}); wolffd@0: end wolffd@0: [mu, Sigma] = condgaussTrainObserved(obsData, hiddenData(:), nstates, varargin{:}); wolffd@0: wolffd@0: