Use a symmetric distribution divergence
Jensen-Shannon divergence compares two distributions through their midpoint. It is symmetric and remains finite for disjoint support, unlike a one-way KL divergence with a zero denominator. The logarithm base determines the scale; this exercise uses natural logs.
A value near zero means similar marginal proportions, not identical joint behavior or stable model quality. Counts must share the same bin vocabulary. Empty or negative histograms are invalid observations, rather than another form of drift. Keep feature construction and bin definitions versioned with the monitoring configuration.
import math
p=[1.,0.];q=[0.,1.];m=[.5,.5]
print(sum(x*math.log(x/y) for x,y in zip(p,m) if x))Review the design
Natural-log Jensen-Shannon divergence lies between zero and log(2). The metric compares the supplied bins, so missing a critical slice or dependency can still hide a production problem.
Your task
Implement js_divergence(a,b), normalizing equal nonempty nonnegative finite count arrays with positive totals. Compute half KL(p||m)+half KL(q||m), skipping zero numerator terms.
The explanation opens here once every check passes.