Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/netlab3.3/gmmpost.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 [post, a] = gmmpost(mix, x) | |
2 %GMMPOST Computes the class posterior probabilities of a Gaussian mixture model. | |
3 % | |
4 % Description | |
5 % This function computes the posteriors POST (i.e. the probability of | |
6 % each component conditioned on the data P(J|X)) for a Gaussian mixture | |
7 % model. The data structure MIX defines the mixture model, while the | |
8 % matrix X contains the data vectors. Each row of X represents a | |
9 % single vector. | |
10 % | |
11 % See also | |
12 % GMM, GMMACTIV, GMMPROB | |
13 % | |
14 | |
15 % Copyright (c) Ian T Nabney (1996-2001) | |
16 | |
17 % Check that inputs are consistent | |
18 errstring = consist(mix, 'gmm', x); | |
19 if ~isempty(errstring) | |
20 error(errstring); | |
21 end | |
22 | |
23 ndata = size(x, 1); | |
24 | |
25 a = gmmactiv(mix, x); | |
26 | |
27 post = (ones(ndata, 1)*mix.priors).*a; | |
28 s = sum(post, 2); | |
29 if any(s==0) | |
30 warning('Some zero posterior probabilities') | |
31 % Set any zeros to one before dividing | |
32 zero_rows = find(s==0); | |
33 s = s + (s==0); | |
34 post(zero_rows, :) = 1/mix.ncentres; | |
35 end | |
36 post = post./(s*ones(1, mix.ncentres)); |