Information theory
Jensen-Shannon divergence
info.js-divergenceAlso called js divergence, jensen shannon, jsd, js div
where
Symmetric divergence: the mean KL divergence of p and q from their midpoint m, in nats. It is bounded by ln 2.
Notation
probability vector
p ∈ Δn: pi > 0, ∑pi = 1
second probability vector
q ∈ Δn: qi > 0, ∑qi = 1
number of outcomes
Size, at least 2
Result: the divergence, in nats
scalar
Worked examples
Each result is solved exactly and confirmed by two independent computations.
Given
Result
Given
Result
≈ 0.130812035941
Given
Result
≈ 0.0566330122651
Given
Result
≈ 0.0338220755686
Common mistakes
Returns the Jensen-Shannon distance
The result is the square root of the divergence, which is what scipy.spatial.distance.jensenshannon returns.
Fix: Square the distance, or compute the divergence directly.
Uses log base 2
The result is in bits.
Fix: Use the natural logarithm, or multiply by ln 2.
Source
Lin 1991
Lin, Jianhua. Divergence measures based on the Shannon entropy. IEEE Transactions on Information Theory 37(1): 145-151, 1991. doi:10.1109/18.61115