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