Computes the Kullback-Leibler divergence \(D_{KL}(p \| q)\) between two probability mass functions.
Details
The KL divergence is defined as: $$D_{KL}(p \| q) = \sum_k p(k) \log\frac{p(k)}{q(k)}$$
Only indices where \(p(k) > \epsilon\) are included in the sum.
Properties:
\(D_{KL}(p \| q) \geq 0\) with equality iff \(p = q\)
Not symmetric: \(D_{KL}(p \| q) \neq D_{KL}(q \| p)\)
See also
kl_divergence_K for KL divergence with induced PMF