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

📄 spm_kl_eig_normal.m.svn-base

📁 try the matlab scripts to do various computations
💻 SVN-BASE
字号:
function [d] = spm_kl_eig_normal (m_q,c_q,c_p)% KL divergence between normal densities using eigendecomposition % function [d] = spm_kl_eig_normal (m_q,c_q,c_p)%% Calculate the KL distance %% KL (Q||P) = <log Q/P> where avg is wrt Q%% between two Normal densities Q and P where P is% zero mean and has a diagonal covariance.%% m_q, c_q    Mean and covariance of first Normal density% c_p         Covariance of second (zero-mean) Normal density%___________________________________________________________________________% Copyright (C) 2007 Wellcome Department of Imaging Neuroscience% Will Penny % $Id$d=length(m_q);m_q=m_q(:);ldcp=0.5*sum(log(diag(c_p)));[v,eigvals]=eig(c_q);ldcq=-0.5*sum(log(diag(eigvals)));Term1=ldcp+ldcq;inv_c_p=diag(1./diag(c_p));Term2=0.5*trace(inv_c_p*c_q)+0.5*m_q'*inv_c_p*m_q;d=Term1+Term2-0.5*d;

⌨️ 快捷键说明

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