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