comparison toolboxes/FullBNT-1.0.7/netlab3.3/gmmunpak.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 mix = gmmunpak(mix, p)
2 %GMMUNPAK Separates a vector of Gaussian mixture model parameters into its components.
3 %
4 % Description
5 % MIX = GMMUNPAK(MIX, P) takes a GMM data structure MIX and a single
6 % row vector of parameters P and returns a mixture data structure
7 % identical to the input MIX, except that the mixing coefficients
8 % PRIORS, centres CENTRES and covariances COVARS (and, for PPCA, the
9 % lambdas and U (PCA sub-spaces)) are all set to the corresponding
10 % elements of P.
11 %
12 % See also
13 % GMM, GMMPAK
14 %
15
16 % Copyright (c) Ian T Nabney (1996-2001)
17
18 errstring = consist(mix, 'gmm');
19 if ~errstring
20 error(errstring);
21 end
22 if mix.nwts ~= length(p)
23 error('Invalid weight vector length')
24 end
25
26 mark1 = mix.ncentres;
27 mark2 = mark1 + mix.ncentres*mix.nin;
28
29 mix.priors = reshape(p(1:mark1), 1, mix.ncentres);
30 mix.centres = reshape(p(mark1 + 1:mark2), mix.ncentres, mix.nin);
31 switch mix.covar_type
32 case 'spherical'
33 mark3 = mix.ncentres*(2 + mix.nin);
34 mix.covars = reshape(p(mark2 + 1:mark3), 1, mix.ncentres);
35 case 'diag'
36 mark3 = mix.ncentres*(1 + mix.nin + mix.nin);
37 mix.covars = reshape(p(mark2 + 1:mark3), mix.ncentres, mix.nin);
38 case 'full'
39 mark3 = mix.ncentres*(1 + mix.nin + mix.nin*mix.nin);
40 mix.covars = reshape(p(mark2 + 1:mark3), mix.nin, mix.nin, ...
41 mix.ncentres);
42 case 'ppca'
43 mark3 = mix.ncentres*(2 + mix.nin);
44 mix.covars = reshape(p(mark2 + 1:mark3), 1, mix.ncentres);
45 % Now also extract k and eigenspaces
46 mark4 = mark3 + mix.ncentres*mix.ppca_dim;
47 mix.lambda = reshape(p(mark3 + 1:mark4), mix.ncentres, ...
48 mix.ppca_dim);
49 mix.U = reshape(p(mark4 + 1:end), mix.nin, mix.ppca_dim, ...
50 mix.ncentres);
51 otherwise
52 error(['Unknown covariance type ', mix.covar_type]);
53 end
54