
Kullback-Leibler divergence between two discrete distributions
Source:R/bnp_ghosal.R
morie_gh_kl.RdRenormalises both inputs to sum to one and returns
\(\sum_i p_i \log(p_i / q_i)\) in nats, restricted to the support
of p. Zeros in q are floored at 1e-300 rather
than returning Inf, so the result is always finite.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_gh_kl(V, V)
#> [1] 0