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

📄 gmm_to_gaussian.m

📁 高斯滤波器 matlab toolbox For GMMs and Gaussian kernels
💻 M
字号:
function [x,P,wn] = gmm_to_gaussian(g)
% Convert gmm to a single Gaussian (ie, compute first two moments of mixture). 

[g, wn] = gmm_normalise(g); % gmm must be normalised for weighted sums to be meaningful

[D,N] = size(g.x);
w = reprow(g.w, D);
x = sum(w.*g.x, 2);

P = zeros(D);
for i=1:N
    P = P + g.w(i) * g.P(:,:,i);
end
xerr = g.x - repcol(x, N);
P = P + w.*xerr*xerr'; 

return 


% TODO: implement faster version: ... 
[D,N] = size(g.x);

w = reprow(g.w, D);
x = sum(w.*g.x, 2);

xerr = g.x - repcol(x, N);
P = reshape(g.P, [N,D*D,1]);
Pw = sum(w.*P, 1);
Pw = reshape(Pw, [D,D]);
%Pw = reshape(sum(w.*reshape(g.P, [N,D*D,1]), 1), [D,D]); % reshape permits summing over P values
P = Pw + w.*xerr*xerr'; 

% g.P is DxDxN
% g.w is N
% w is DxN

⌨️ 快捷键说明

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