?? mogp.m
字號(hào):
function p = mogP(x,means,covs,priors)% p = mogP(x,means,covs,priors)%% Calculate the probability density for each of the clusters of a% mixture of Gaussians (note that P is not normalized!)% Copyright: D. Tax, R.P.W. Duin, davidt@ph.tn.tudelft.nl% Faculty of Applied Physics, Delft University of Technology% P.O. Box 5046, 2600 GA Delft, The Netherlands[N,d] = size(x);k = length(priors);p = zeros(N,k);covtype = ndims(covs);if ((covtype==2)&(size(covs,2)==1)) covtype = 1;endswitch covtype case 1 D = distm(x,means); sig = ones(N,1)*(2.*covs'); Z = (pi*sig).^(d/2); p = exp(-(D./sig))./Z; case 2 Z = (2*pi).^(d/2); sig = prod(sqrt(covs),2); for i=1:k dif = x - ones(N,1)*means(i,:); p(:,i) = exp(-sum((dif.*dif)./(ones(N,1)*covs(i,:)) ,2)/2) ./ ... (Z*sig(i)); end case 3 Z = (2*pi).^(d/2); for i=1:k dif = x - ones(N,1)*means(i,:); c = chol(squeeze(covs(i,:,:))); Dmah = dif/c; p(:,i) = exp(-sum(Dmah.*Dmah,2)/2) ./ (Z*prod(diag(c))); end otherwise error('The covariance matrix parameter is not well-defined');end% include the priors:p = p.*(ones(N,1)*priors);return
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -