Daniel@0: function g = demgpot(x, mix) Daniel@0: %DEMGPOT Computes the gradient of the negative log likelihood for a mixture model. Daniel@0: % Daniel@0: % Description Daniel@0: % This function computes the gradient of the negative log of the Daniel@0: % unconditional data density P(X) with respect to the coefficients of Daniel@0: % the data vector X for a Gaussian mixture model. The data structure Daniel@0: % MIX defines the mixture model, while the matrix X contains the data Daniel@0: % vector as a row vector. Note the unusual order of the arguments: this Daniel@0: % is so that the function can be used in DEMHMC1 directly for sampling Daniel@0: % from the distribution P(X). Daniel@0: % Daniel@0: % See also Daniel@0: % DEMHMC1, DEMMET1, DEMPOT Daniel@0: % Daniel@0: Daniel@0: % Copyright (c) Ian T Nabney (1996-2001) Daniel@0: Daniel@0: % Computes the potential gradient Daniel@0: Daniel@0: temp = (ones(mix.ncentres,1)*x)-mix.centres; Daniel@0: temp = temp.*(gmmactiv(mix,x)'*ones(1, mix.nin)); Daniel@0: % Assume spherical covariance structure Daniel@0: if ~strcmp(mix.covar_type, 'spherical') Daniel@0: error('Spherical covariance only.') Daniel@0: end Daniel@0: temp = temp./(mix.covars'*ones(1, mix.nin)); Daniel@0: temp = temp.*(mix.priors'*ones(1, mix.nin)); Daniel@0: g = sum(temp, 1)/gmmprob(mix, x);