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