pyhgf.math.dirichlet_kullback_leibler#

pyhgf.math.dirichlet_kullback_leibler(alpha_1: Array | ndarray | bool_ | number | bool | int | float | complex, alpha_2: Array | ndarray | bool_ | number | bool | int | float | complex) Array[source]#

Compute the Kullback-Leibler divergence between two Dirichlet distributions.

The Kullback-Leibler divergence from the distribution \(Q\) to the distribution \(P\), two Dirichlet distributions parametrized by \(\alpha_2\) and \(\alpha_1\) (respectively) is given by the following equation:

\[KL[P||Q] = \ln{\frac{\Gamma(\sum_{i=1}^k\alpha_{1i})} {\Gamma(\sum_{i=1}^k\alpha_{2i})}} + \sum_{i=1}^k \ln{\frac{\Gamma(\alpha_{2i})}{\Gamma(\alpha_{1i})}} + \sum_{i=1}^k(\alpha_{1i} - \alpha_{2i})\left[\psi(\alpha_{1i})-\psi(\sum_{i=1}^k\alpha_{1i})\right]\]
Parameters:
alpha_1

The concentration parameters for the distribution \(P\).

alpha_2

The concentration parameters for the distribution \(Q\).

Returns:
kl

The Kullback-Leibler divergence of distribution \(P\) from distribution \(Q\).

References

[2]

Penny, William D. (2001): “KL-Divergences of Normal, Gamma, Dirichlet and Wishart densities” ; in: University College, London , p. 2, eqs. 8-9 ; URL: https://www.fil.ion.ucl.ac.uk/~wpenny/publications/densities.ps .