{"id":"jensen_shannon","title":"Jensen-Shannon distance","family":"lock-step","definition":"reference","intro_en":"Jensen-Shannon distance compares two probability vectors through their midpoint distribution. Each side contributes a KL divergence to that midpoint, the two values are averaged, and the square root produces the distance shown here. The animated bins share a fixed support; their positions describe probability mass rather than a time-warping alignment.","intro_zh":"Jensen-Shannon 距离以两概率向量的中点分布作为共同参照，平均两侧到中点的 KL 散度，再开平方。本动画使用固定共同支持集；横轴位置表示概率质量所在的箱，而不是时间规整的匹配位置。","steps_en":["Declare one shared bin support and normalize nonnegative mass to sum to one.","Compute each bin's two-sided KL-to-midpoint contribution.","Accumulate the displayed bin contributions, retaining any signed terms.","Take the square root of the averaged divergence."],"steps_zh":["声明共同箱支持集，将非负质量归一化为概率。","按该方法公式计算逐箱贡献。","累加所示贡献，保留可能出现的符号。","应用所示最后的根号、对数或直接求和。"],"formula":"sqrt(0.5*KL(p||m)+0.5*KL(q||m)); m=(p+q)/2; natural logarithm","caveats_en":["This card shows the square root, not raw JS divergence.","Logarithm base changes the scale; natural logs are used here."],"caveats_zh":["本条目展示平方根形式，并非原始 JS 散度。","对数底改变数值尺度，本例使用自然对数。"],"sources":[{"label":"SciPy: jensenshannon","url":"https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.jensenshannon.html"}],"x":[1.0,3.0,6.0,9.0,7.0,4.0,2.0,1.0],"y":[1.0,2.0,3.0,6.0,9.0,7.0,4.0,2.0],"input_label":"Synthetic counts on eight shared bins; these bins are not timestamps.","parameters":{"probability_p":[0.030303030303030304,0.09090909090909091,0.18181818181818182,0.2727272727272727,0.21212121212121213,0.12121212121212122,0.06060606060606061,0.030303030303030304],"probability_q":[0.029411764705882353,0.058823529411764705,0.08823529411764706,0.17647058823529413,0.2647058823529412,0.20588235294117646,0.11764705882352941,0.058823529411764705],"log_base":"e","smoothing":"none","support":"eight shared illustrative bins"},"result":{"label":"distance","value":0.1707987088027245,"detail":""},"frames":[{"phase":0,"caption":"Probability mass on shared bins","panel":{"kind":"lines","title":"Probability mass on shared bins","a":[0.030303030303030304,0.09090909090909091],"a_label":"x","b":[0.029411764705882353,0.058823529411764705],"b_label":"y","marker":1}},{"phase":0,"caption":"Probability mass on shared bins","panel":{"kind":"lines","title":"Probability mass on shared bins","a":[0.030303030303030304,0.09090909090909091,0.18181818181818182,0.2727272727272727],"a_label":"x","b":[0.029411764705882353,0.058823529411764705,0.08823529411764706,0.17647058823529413],"b_label":"y","marker":3}},{"phase":0,"caption":"Probability mass on shared bins","panel":{"kind":"lines","title":"Probability mass on shared bins","a":[0.030303030303030304,0.09090909090909091,0.18181818181818182,0.2727272727272727,0.21212121212121213,0.12121212121212122],"a_label":"x","b":[0.029411764705882353,0.058823529411764705,0.08823529411764706,0.17647058823529413,0.2647058823529412,0.20588235294117646],"b_label":"y","marker":5}},{"phase":0,"caption":"Probability mass on shared bins","panel":{"kind":"lines","title":"Probability mass on shared bins","a":[0.030303030303030304,0.09090909090909091,0.18181818181818182,0.2727272727272727,0.21212121212121213,0.12121212121212122,0.06060606060606061,0.030303030303030304],"a_label":"x","b":[0.029411764705882353,0.058823529411764705,0.08823529411764706,0.17647058823529413,0.2647058823529412,0.20588235294117646,0.11764705882352941,0.058823529411764705],"b_label":"y","marker":7}},{"phase":1,"caption":"Compute coordinate 1: Compute each bin's two-sided KL-to-midpoint contribution","panel":{"kind":"bars","title":"Compute each bin's two-sided KL-to-midpoint contribution","a":[3.32574138366522e-06,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":0},"value":3.32574138366522e-06,"value_label":"coordinate term","input_highlight":[0]},{"phase":1,"caption":"Compute coordinate 3: Compute each bin's two-sided KL-to-midpoint contribution","panel":{"kind":"bars","title":"Compute each bin's two-sided KL-to-midpoint contribution","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":2},"value":0.008278030101545947,"value_label":"coordinate term","input_highlight":[2]},{"phase":1,"caption":"Compute coordinate 5: Compute each bin's two-sided KL-to-midpoint contribution","panel":{"kind":"bars","title":"Compute each bin's two-sided KL-to-midpoint contribution","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.0,0.0,0.0],"a_label":"contribution","marker":4},"value":0.0014527172764795,"value_label":"coordinate term","input_highlight":[4]},{"phase":1,"caption":"Compute coordinate 8: Compute each bin's two-sided KL-to-midpoint contribution","panel":{"kind":"bars","title":"Compute each bin's two-sided KL-to-midpoint contribution","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.005542233787927817,0.004644536780640796,0.002322268390320398],"a_label":"contribution","marker":7},"value":0.002322268390320398,"value_label":"coordinate term","input_highlight":[7]},{"phase":2,"caption":"Accumulate 1 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[3.32574138366522e-06,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":0},"value":3.32574138366522e-06,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 2 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[3.32574138366522e-06,0.0017322717125949497,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":1},"value":0.0017355974539786149,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 3 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":2},"value":0.010013627555524563,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 4 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":3},"value":0.015210442693309371,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 5 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.0,0.0,0.0],"a_label":"contribution","marker":4},"value":0.01666315996978887,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 6 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.005542233787927817,0.0,0.0],"a_label":"contribution","marker":5},"value":0.02220539375771669,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 7 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.005542233787927817,0.004644536780640796,0.0],"a_label":"contribution","marker":6},"value":0.026849930538357485,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 8 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.005542233787927817,0.004644536780640796,0.002322268390320398],"a_label":"contribution","marker":7},"value":0.02917219892867788,"value_label":"running sum"},{"phase":3,"caption":"Take the square root of the averaged divergence","panel":{"kind":"bars","title":"Compute each bin's two-sided KL-to-midpoint contribution","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.005542233787927817,0.004644536780640796,0.002322268390320398],"a_label":"contribution","marker":0},"value":0.1707987088027245,"value_label":"final result"},{"phase":3,"caption":"Take the square root of the averaged divergence","panel":{"kind":"bars","title":"Compute each bin's two-sided KL-to-midpoint contribution","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.005542233787927817,0.004644536780640796,0.002322268390320398],"a_label":"contribution","marker":2},"value":0.1707987088027245,"value_label":"final result"},{"phase":3,"caption":"Take the square root of the averaged divergence","panel":{"kind":"bars","title":"Compute each bin's two-sided KL-to-midpoint contribution","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.005542233787927817,0.004644536780640796,0.002322268390320398],"a_label":"contribution","marker":4},"value":0.1707987088027245,"value_label":"final result"},{"phase":3,"caption":"Take the square root of the averaged divergence","panel":{"kind":"bars","title":"Compute each bin's two-sided KL-to-midpoint contribution","a":[3.32574138366522e-06,0.0017322717125949497,0.008278030101545947,0.005196815137784808,0.0014527172764795,0.005542233787927817,0.004644536780640796,0.002322268390320398],"a_label":"contribution","marker":7},"value":0.1707987088027245,"value_label":"final result"}],"animation_steps_en":["Normalize counts on one shared bin support.","Compute each bin's two-sided KL-to-midpoint contribution.","Accumulate the displayed bin contributions.","Take the square root of the averaged divergence."],"echotime_status":"Conceptually covered","echotime_api":"spectral_similarity"}
