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