Dear SPM users

I'm wondering if there might be a minor mistake in the calculation of the KL-divergence for two gamma densities in function spm_kl_gamma in line 18:
d=d+b_q*c_q/b_p;
with
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

If I'm correct I would say that line18 should be changed to:
d=d+b_p*c_q/b_q;

see e.g. Matthew Beal's PhD thesis Appendix A (http://www.cse.buffalo.edu/faculty/mbeal/papers/beal03.pdf).

Please let me know what you think. I hope you can help me clarify my uncertainty about the calculation.

Best regards,
Carsten

--
Carsten Stahlhut, Ph.d.-student
Informatics and Mathematical Modelling
Richard Petersens Plads, B321/128
Technical University of Denmark