annotate toolboxes/FullBNT-1.0.7/HMM/gausshmm_train_observed.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function [initState, transmat, mu, Sigma] = gausshmm_train_observed(obsData, hiddenData, ...
Daniel@0 2 nstates, varargin)
Daniel@0 3 % GAUSSHMM_TRAIN_OBSERVED Estimate params of HMM with Gaussian output from fully observed sequences
Daniel@0 4 % [initState, transmat, mu, Sigma] = gausshmm_train_observed(obsData, hiddenData, nstates,...)
Daniel@0 5 %
Daniel@0 6 % INPUT
Daniel@0 7 % If all sequences have the same length
Daniel@0 8 % obsData(:,t,ex)
Daniel@0 9 % hiddenData(ex,t) - must be ROW vector if only one sequence
Daniel@0 10 % If sequences have different lengths, we use cell arrays
Daniel@0 11 % obsData{ex}(:,t)
Daniel@0 12 % hiddenData{ex}(t)
Daniel@0 13 %
Daniel@0 14 % Optional argumnets
Daniel@0 15 % dirichletPriorWeight - for smoothing transition matrix counts
Daniel@0 16 %
Daniel@0 17 % Optional parameters from mixgauss_Mstep:
Daniel@0 18 % 'cov_type' - 'full', 'diag' or 'spherical' ['full']
Daniel@0 19 % 'tied_cov' - 1 (Sigma) or 0 (Sigma_i) [0]
Daniel@0 20 % 'clamped_cov' - pass in clamped value, or [] if unclamped [ [] ]
Daniel@0 21 % 'clamped_mean' - pass in clamped value, or [] if unclamped [ [] ]
Daniel@0 22 % 'cov_prior' - Lambda_i, added to YY(:,:,i) [0.01*eye(d,d,Q)]
Daniel@0 23 %
Daniel@0 24 % Output
Daniel@0 25 % mu(:,q)
Daniel@0 26 % Sigma(:,:,q)
Daniel@0 27
Daniel@0 28 [dirichletPriorWeight, other] = process_options(...
Daniel@0 29 varargin, 'dirichletPriorWeight', 0);
Daniel@0 30
Daniel@0 31 [transmat, initState] = transmat_train_observed(hiddenData, nstates, ...
Daniel@0 32 'dirichletPriorWeight', dirichletPriorWeight);
Daniel@0 33
Daniel@0 34 % convert to obsData(:,t*nex)
Daniel@0 35 if ~iscell(obsData)
Daniel@0 36 [D T Nex] = size(obsData);
Daniel@0 37 obsData = reshape(obsData, D, T*Nex);
Daniel@0 38 else
Daniel@0 39 obsData = cat(2, obsData{:});
Daniel@0 40 hiddenData = cat(2,hiddenData{:});
Daniel@0 41 end
Daniel@0 42 [mu, Sigma] = condgaussTrainObserved(obsData, hiddenData(:), nstates, varargin{:});
Daniel@0 43
Daniel@0 44