annotate toolboxes/FullBNT-1.0.7/netlab3.3/mdnprob.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function [prob,a] = mdnprob(mixparams, t)
Daniel@0 2 %MDNPROB Computes the data probability likelihood for an MDN mixture structure.
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 % PROB = MDNPROB(MIXPARAMS, T) computes the probability P(T) of each
Daniel@0 6 % data vector in T under the Gaussian mixture model represented by the
Daniel@0 7 % corresponding entries in MIXPARAMS. Each row of T represents a single
Daniel@0 8 % vector.
Daniel@0 9 %
Daniel@0 10 % [PROB, A] = MDNPROB(MIXPARAMS, T) also computes the activations A
Daniel@0 11 % (i.e. the probability P(T|J) of the data conditioned on each
Daniel@0 12 % component density) for a Gaussian mixture model.
Daniel@0 13 %
Daniel@0 14 % See also
Daniel@0 15 % MDNERR, MDNPOST
Daniel@0 16 %
Daniel@0 17
Daniel@0 18 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 19 % David J Evans (1998)
Daniel@0 20
Daniel@0 21 % Check arguments for consistency
Daniel@0 22 errstring = consist(mixparams, 'mdnmixes');
Daniel@0 23 if ~isempty(errstring)
Daniel@0 24 error(errstring);
Daniel@0 25 end
Daniel@0 26
Daniel@0 27 ntarget = size(t, 1);
Daniel@0 28 if ntarget ~= size(mixparams.centres, 1)
Daniel@0 29 error('Number of targets does not match number of mixtures')
Daniel@0 30 end
Daniel@0 31 if size(t, 2) ~= mixparams.dim_target
Daniel@0 32 error('Target dimension does not match mixture dimension')
Daniel@0 33 end
Daniel@0 34
Daniel@0 35 dim_target = mixparams.dim_target;
Daniel@0 36 ntarget = size(t, 1);
Daniel@0 37
Daniel@0 38 % Calculate squared norm matrix, of dimension (ndata, ncentres)
Daniel@0 39 % vector (ntarget * ncentres)
Daniel@0 40 dist2 = mdndist2(mixparams, t);
Daniel@0 41
Daniel@0 42 % Calculate variance factors
Daniel@0 43 variance = 2.*mixparams.covars;
Daniel@0 44
Daniel@0 45 % Compute the normalisation term
Daniel@0 46 normal = ((2.*pi).*mixparams.covars).^(dim_target./2);
Daniel@0 47
Daniel@0 48 % Now compute the activations
Daniel@0 49 a = exp(-(dist2./variance))./normal;
Daniel@0 50
Daniel@0 51 % Accumulate negative log likelihood of targets
Daniel@0 52 prob = mixparams.mixcoeffs.*a;