wolffd@0: function gmmmixes = mdn2gmm(mdnmixes) wolffd@0: %MDN2GMM Converts an MDN mixture data structure to array of GMMs. wolffd@0: % wolffd@0: % Description wolffd@0: % GMMMIXES = MDN2GMM(MDNMIXES) takes an MDN mixture data structure wolffd@0: % MDNMIXES containing three matrices (for priors, centres and wolffd@0: % variances) where each row represents the corresponding parameter wolffd@0: % values for a different mixture model and creates an array of GMMs. wolffd@0: % These can then be used with the standard Netlab Gaussian mixture wolffd@0: % model functions. wolffd@0: % wolffd@0: % See also wolffd@0: % GMM, MDN, MDNFWD wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: % David J Evans (1998) wolffd@0: wolffd@0: % Check argument for consistency wolffd@0: errstring = consist(mdnmixes, 'mdnmixes'); wolffd@0: if ~isempty(errstring) wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: nmixes = size(mdnmixes.centres, 1); wolffd@0: % Construct ndata structures containing the mixture model information. wolffd@0: % First allocate the memory. wolffd@0: tempmix = gmm(mdnmixes.dim_target, mdnmixes.ncentres, 'spherical'); wolffd@0: f = fieldnames(tempmix); wolffd@0: gmmmixes = cell(size(f, 1), 1, nmixes); wolffd@0: gmmmixes = cell2struct(gmmmixes, f,1); wolffd@0: wolffd@0: % Then fill each structure in turn using gmmunpak. Assume that spherical wolffd@0: % covariance structure is used. wolffd@0: for i = 1:nmixes wolffd@0: centres = reshape(mdnmixes.centres(i, :), mdnmixes.dim_target, ... wolffd@0: mdnmixes.ncentres)'; wolffd@0: gmmmixes(i) = gmmunpak(tempmix, [mdnmixes.mixcoeffs(i,:), ... wolffd@0: centres(:)', mdnmixes.covars(i,:)]); wolffd@0: end wolffd@0: