annotate toolboxes/FullBNT-1.0.7/netlab3.3/mdn2gmm.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function gmmmixes = mdn2gmm(mdnmixes)
wolffd@0 2 %MDN2GMM Converts an MDN mixture data structure to array of GMMs.
wolffd@0 3 %
wolffd@0 4 % Description
wolffd@0 5 % GMMMIXES = MDN2GMM(MDNMIXES) takes an MDN mixture data structure
wolffd@0 6 % MDNMIXES containing three matrices (for priors, centres and
wolffd@0 7 % variances) where each row represents the corresponding parameter
wolffd@0 8 % values for a different mixture model and creates an array of GMMs.
wolffd@0 9 % These can then be used with the standard Netlab Gaussian mixture
wolffd@0 10 % model functions.
wolffd@0 11 %
wolffd@0 12 % See also
wolffd@0 13 % GMM, MDN, MDNFWD
wolffd@0 14 %
wolffd@0 15
wolffd@0 16 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 17 % David J Evans (1998)
wolffd@0 18
wolffd@0 19 % Check argument for consistency
wolffd@0 20 errstring = consist(mdnmixes, 'mdnmixes');
wolffd@0 21 if ~isempty(errstring)
wolffd@0 22 error(errstring);
wolffd@0 23 end
wolffd@0 24
wolffd@0 25 nmixes = size(mdnmixes.centres, 1);
wolffd@0 26 % Construct ndata structures containing the mixture model information.
wolffd@0 27 % First allocate the memory.
wolffd@0 28 tempmix = gmm(mdnmixes.dim_target, mdnmixes.ncentres, 'spherical');
wolffd@0 29 f = fieldnames(tempmix);
wolffd@0 30 gmmmixes = cell(size(f, 1), 1, nmixes);
wolffd@0 31 gmmmixes = cell2struct(gmmmixes, f,1);
wolffd@0 32
wolffd@0 33 % Then fill each structure in turn using gmmunpak. Assume that spherical
wolffd@0 34 % covariance structure is used.
wolffd@0 35 for i = 1:nmixes
wolffd@0 36 centres = reshape(mdnmixes.centres(i, :), mdnmixes.dim_target, ...
wolffd@0 37 mdnmixes.ncentres)';
wolffd@0 38 gmmmixes(i) = gmmunpak(tempmix, [mdnmixes.mixcoeffs(i,:), ...
wolffd@0 39 centres(:)', mdnmixes.covars(i,:)]);
wolffd@0 40 end
wolffd@0 41