Daniel@0: function [prob,a] = mdnprob(mixparams, t) Daniel@0: %MDNPROB Computes the data probability likelihood for an MDN mixture structure. Daniel@0: % Daniel@0: % Description Daniel@0: % PROB = MDNPROB(MIXPARAMS, T) computes the probability P(T) of each Daniel@0: % data vector in T under the Gaussian mixture model represented by the Daniel@0: % corresponding entries in MIXPARAMS. Each row of T represents a single Daniel@0: % vector. Daniel@0: % Daniel@0: % [PROB, A] = MDNPROB(MIXPARAMS, T) also computes the activations A Daniel@0: % (i.e. the probability P(T|J) of the data conditioned on each Daniel@0: % component density) for a Gaussian mixture model. Daniel@0: % Daniel@0: % See also Daniel@0: % MDNERR, MDNPOST Daniel@0: % Daniel@0: Daniel@0: % Copyright (c) Ian T Nabney (1996-2001) Daniel@0: % David J Evans (1998) Daniel@0: Daniel@0: % Check arguments for consistency Daniel@0: errstring = consist(mixparams, 'mdnmixes'); Daniel@0: if ~isempty(errstring) Daniel@0: error(errstring); Daniel@0: end Daniel@0: Daniel@0: ntarget = size(t, 1); Daniel@0: if ntarget ~= size(mixparams.centres, 1) Daniel@0: error('Number of targets does not match number of mixtures') Daniel@0: end Daniel@0: if size(t, 2) ~= mixparams.dim_target Daniel@0: error('Target dimension does not match mixture dimension') Daniel@0: end Daniel@0: Daniel@0: dim_target = mixparams.dim_target; Daniel@0: ntarget = size(t, 1); Daniel@0: Daniel@0: % Calculate squared norm matrix, of dimension (ndata, ncentres) Daniel@0: % vector (ntarget * ncentres) Daniel@0: dist2 = mdndist2(mixparams, t); Daniel@0: Daniel@0: % Calculate variance factors Daniel@0: variance = 2.*mixparams.covars; Daniel@0: Daniel@0: % Compute the normalisation term Daniel@0: normal = ((2.*pi).*mixparams.covars).^(dim_target./2); Daniel@0: Daniel@0: % Now compute the activations Daniel@0: a = exp(-(dist2./variance))./normal; Daniel@0: Daniel@0: % Accumulate negative log likelihood of targets Daniel@0: prob = mixparams.mixcoeffs.*a;