Home > spm_vbglmar_slice > spm_kl_gamma.m

spm_kl_gamma

PURPOSE ^

KL divergence for Gamma densities

SYNOPSIS ^

function [d] = spm_kl_gamma (b_q,c_q,b_p,c_p)

DESCRIPTION ^

 KL divergence for Gamma densities
 FORMAT [d] = spm_kl_gamma (b_q,c_q,b_p,c_p)

 KL (Q||P) = <log Q/P> where avg is wrt Q

 b_q, c_q    Parameters of first Gamma density
 b_p, c_p    Parameters of second Gamma density

 %W% Will Penny %E%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [d] = spm_kl_gamma (b_q,c_q,b_p,c_p)
0002 % KL divergence for Gamma densities
0003 % FORMAT [d] = spm_kl_gamma (b_q,c_q,b_p,c_p)
0004 %
0005 % KL (Q||P) = <log Q/P> where avg is wrt Q
0006 %
0007 % b_q, c_q    Parameters of first Gamma density
0008 % b_p, c_p    Parameters of second Gamma density
0009 %
0010 % %W% Will Penny %E%
0011 
0012 digamma_c_q=spm_digamma(c_q);
0013 d=(c_q-1)*digamma_c_q-log(b_q)-c_q-gammaln(c_q);
0014 d=d+gammaln(c_p)+c_p*log(b_p)-(c_p-1)*(digamma_c_q+log(b_q));
0015 d=d+b_q*c_q/b_p;
0016 
0017

Generated on Mon 23-Aug-2004 14:59:38 by m2html © 2003