hmmdatainit.m

来自「CHMMBOX, version 1.2, Iead Rezek, Oxford」· M 代码 · 共 51 行

M
51
字号
function [hmm] = hmmdatainit (X,hmm,covtype)% function [hmm] = hmmdatainit (X,hmm,covtype)%% Initialise Gaussian observation HMM model % uses the data to initialise static Gaussian Mixture Model%% X		N x p data matrix% hmm		hmm data structure% covtype	'full' or 'diag' covariance matricesN=size(X,1);p=size(X,2);mix.ncentres=hmm.K;% get some ranges within which the random values should lieinitmean=mean(X);initvar=cov(X);%  inititalisation; for k=1:mix.ncentres,   mix.centres(k,:)=initmean;   if covtype=='full',      mix.covars(:,:,k)=initvar;   elseif covtype=='diag',      mix.covars(k,:)=diag(initvar)';   else      error('Unknown type of covariance matrix');   end;end;   hmm.gmmll=0;     % Log likelihood of gmm model; not used in rand. init.for k=1:mix.ncentres;  hmm.state(k).Mu=mix.centres(k,:);  switch covtype    case 'full',      hmm.state(k).Cov=squeeze(mix.covars(:,:,k));      hmm.init_val(k).Cov = hmm.state(k).Cov;  % In case we need to re-init    case 'diag',      hmm.state(k).Cov=diag(mix.covars(k,:));      hmm.init_val(k).Cov = hmm.state(k).Cov; % In case we need to re-init    otherwise,            disp('Unknown type of covariance matrix');  endendhmm.train.init='gmm';hmm.mix=mix;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?