⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mogp.m

📁 模式识别工具箱,希望对大家有用!
💻 M
字号:
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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -