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

📄 gmm_entropy.m

📁 高斯滤波器 matlab toolbox For GMMs and Gaussian kernels
💻 M
字号:
function p = gmm_entropy(g,N)

g = gmm_normalise(g);

if nargin == 2
    p = gmm_entropy_montecarlo(g, N);
else
    p = gmm_entropy_unscented(g);
end

%
%

function p = gmm_entropy_montecarlo(g, N)
% Monte Carlo approximation of entropy for Gaussian mixtures.
s = gmm_samples(g, N);
w = gmm_evaluate(g, s);
p = -mean(log(w(w~=0)));

%
%

function p = gmm_entropy_unscented(g)
% Unscented gmm entropy, based on Goldberger's KLD approximation
[D,N] = size(g.x); 
Ds = sqrt(D);

p = 0;
for i=1:N
    Ps = Ds * matrix_square_root(g.P(:,:,i), 1);
    x = repvec(g.x(:,i), D);
    s = [x+Ps, x-Ps]; % unscented samples for i-th component of g
    
    w = gmm_evaluate(g, s);
    p = p - g.w(i)*sum(log(w));    
end
p = p/(2*D);

%
%

function R = matrix_square_root(P, type)
switch type
    case 1 % svd decomposition, P = U*D*U' = R*R' (UDU form is also called modified Cholesky decomposition)
        [U,D,V] = svd(P);
        R = U*sqrt(D);
    case 2 % cholesky decomposition (triangular), P = R*R'
        R = chol(P)';
    case 3 % principal square root (symmetric), P = R*R
        R = sqrtm(P);
end

⌨️ 快捷键说明

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