function p=gaussian(x,m,C);% p=gaussian(x,m,C);%% Evaluate the multi-variate density with mean vector m and covariance% matrix C for the input vector x.% % p=gaussian(X,m,C);% % Vectorized version: Here X is a matrix of column vectors, and p is % a vector of probabilities for each vector.d=length(m);if size(x,1)~=dx=x';endN=size(x,2);detC = det(C);if rcond(C)<eps% fprintf(1,'Covariance matrix close to singular. (gaussian.m)\n');p = zeros(N,1);elsem=m(:);M=m*ones(1,N);denom=(2*pi)^(d/2)*sqrt(abs(detC));mahal=sum(((x-M)'*inv(C)).*(x-M)',2); % Chris Bregler's tricknumer=exp(-0.5*mahal);p=numer/denom;end
添加回答
举报
0/150
提交
取消