View source: R/belief_trajectory.R
| kl_divergence_log10 | R Documentation |
Computes the Kullback-Leibler divergence D_{\mathrm{KL}}(p \| q)
between two distributions, in base-10 logarithm so the result is
expressed in bans.
kl_divergence_log10(p, q, epsilon = 1e-20)
p |
Numeric vector. Target distribution. |
q |
Numeric vector. Reference distribution (same length as |
epsilon |
Numeric scalar. Small positive constant to avoid
|
Numeric scalar. D_{\mathrm{KL}}(p \| q) = \sum_i p_i
\log_{10}(p_i / q_i) in bans.
entropy_log10,
trajectory_metrics.
p <- c(0.7, 0.3)
q <- c(0.5, 0.5)
kl_divergence_log10(p, q) # positive
kl_divergence_log10(p, p) # 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.