comparison toolboxes/FullBNT-1.0.7/netlab3.3/mdnprob.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 [prob,a] = mdnprob(mixparams, t)
2 %MDNPROB Computes the data probability likelihood for an MDN mixture structure.
3 %
4 % Description
5 % PROB = MDNPROB(MIXPARAMS, T) computes the probability P(T) of each
6 % data vector in T under the Gaussian mixture model represented by the
7 % corresponding entries in MIXPARAMS. Each row of T represents a single
8 % vector.
9 %
10 % [PROB, A] = MDNPROB(MIXPARAMS, T) also computes the activations A
11 % (i.e. the probability P(T|J) of the data conditioned on each
12 % component density) for a Gaussian mixture model.
13 %
14 % See also
15 % MDNERR, MDNPOST
16 %
17
18 % Copyright (c) Ian T Nabney (1996-2001)
19 % David J Evans (1998)
20
21 % Check arguments for consistency
22 errstring = consist(mixparams, 'mdnmixes');
23 if ~isempty(errstring)
24 error(errstring);
25 end
26
27 ntarget = size(t, 1);
28 if ntarget ~= size(mixparams.centres, 1)
29 error('Number of targets does not match number of mixtures')
30 end
31 if size(t, 2) ~= mixparams.dim_target
32 error('Target dimension does not match mixture dimension')
33 end
34
35 dim_target = mixparams.dim_target;
36 ntarget = size(t, 1);
37
38 % Calculate squared norm matrix, of dimension (ndata, ncentres)
39 % vector (ntarget * ncentres)
40 dist2 = mdndist2(mixparams, t);
41
42 % Calculate variance factors
43 variance = 2.*mixparams.covars;
44
45 % Compute the normalisation term
46 normal = ((2.*pi).*mixparams.covars).^(dim_target./2);
47
48 % Now compute the activations
49 a = exp(-(dist2./variance))./normal;
50
51 % Accumulate negative log likelihood of targets
52 prob = mixparams.mixcoeffs.*a;