JensenShannonDivergence

A symmetric, bounded distance between two distributions, built from their mixture

Infrastructure · Primitives · brainference 1.0.0

Mechanism

The Kullback-Leibler divergence D_KL(P||Q) = sum_i p_i log(p_i/q_i) measures the information lost when Q approximates P, but it is asymmetric and infinite wherever q_i = 0 and p_i > 0, which empirical histograms with unseen states often produce. The Jensen-Shannon divergence fixes this by comparing both distributions to their mixture M = (P+Q)/2: D_JS = 1/2 D_KL(P||M) + 1/2 D_KL(Q||M). Equivalently D_JS = ShannonEntropy(M) - (H(P)+H(Q))/2. With log base 2 it is symmetric, always finite and bounded in [0, 1], and zero only when P = Q. Typical use: compare an empirical distribution with a null-model distribution over the same state space, so the value reads as distance from the baseline.

Invariants

Failure modes

Where this came from

Builds on

Used by

Identity