kl_divergence_log10: Kullback-Leibler divergence in base-10 (bans)

View source: R/belief_trajectory.R

kl_divergence_log10R Documentation

Kullback-Leibler divergence in base-10 (bans)

Description

Computes the Kullback-Leibler divergence D_{\mathrm{KL}}(p \| q) between two distributions, in base-10 logarithm so the result is expressed in bans.

Usage

kl_divergence_log10(p, q, epsilon = 1e-20)

Arguments

p

Numeric vector. Target distribution.

q

Numeric vector. Reference distribution (same length as p).

epsilon

Numeric scalar. Small positive constant to avoid \log(0). Default 10^{-20}.

Value

Numeric scalar. D_{\mathrm{KL}}(p \| q) = \sum_i p_i \log_{10}(p_i / q_i) in bans.

See Also

entropy_log10, trajectory_metrics.

Examples

p <- c(0.7, 0.3)
q <- c(0.5, 0.5)
kl_divergence_log10(p, q)          # positive
kl_divergence_log10(p, p)          # 0


mispitools documentation built on Aug. 26, 2026, 1:08 a.m.