{"id":"jeffreys_divergence","title":"Jeffreys divergence","family":"lock-step","definition":"reference","intro_en":"Jeffreys divergence adds KL divergences in both directions. On strictly positive probabilities the two terms combine into a per-bin product of the probability difference and its log ratio. The animation shows this symmetric contribution directly. Symmetrizing KL removes its directional asymmetry while leaving a divergence whose metric properties need separate analysis.","intro_zh":"Jeffreys 散度相加两个方向的 KL 散度。概率严格为正时，可逐箱写成概率差与对数比的乘积。动图直接展示该对称贡献；对称化消除了方向不对称，但不能自动赋予其度量性质。","steps_en":["Declare one shared bin support and normalize nonnegative mass to sum to one.","Combine KL terms in both directions.","Accumulate the displayed bin contributions, retaining any signed terms.","Sum the symmetric log-ratio contributions."],"steps_zh":["声明共同箱支持集，将非负质量归一化为概率。","按该方法公式计算逐箱贡献。","累加所示贡献，保留可能出现的符号。","应用所示最后的根号、对数或直接求和。"],"formula":"KL(p||q)+KL(q||p)=sum_i (p_i-q_i)*log(p_i/q_i)","caveats_en":["Symmetry alone does not establish a metric.","A support mismatch can make the result infinite; no smoothing is hidden in this illustration."],"caveats_zh":["对称性本身不能证明度量性质。","支持集不匹配可能使结果无穷；本例没有隐藏平滑。"],"sources":[{"label":"SciPy: entropy","url":"https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html"},{"label":"Imported registry: two-sided KL convention","url":"https://github.com/ZipengWu365/EchoTime/blob/main/src/echotime/data/ts_similarity_package_v2_registry.csv"}],"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":"divergence","value":0.2368098128186838,"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: Combine KL terms in both directions","panel":{"kind":"bars","title":"Combine KL terms in both directions","a":[2.6606919028236338e-05,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":0},"value":2.6606919028236338e-05,"value_label":"coordinate term","input_highlight":[0]},{"phase":1,"caption":"Compute coordinate 3: Combine KL terms in both directions","panel":{"kind":"bars","title":"Combine KL terms in both directions","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":2},"value":0.06766044125624845,"value_label":"coordinate term","input_highlight":[2]},{"phase":1,"caption":"Compute coordinate 5: Combine KL terms in both directions","panel":{"kind":"bars","title":"Combine KL terms in both directions","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.0,0.0,0.0],"a_label":"contribution","marker":4},"value":0.011645478112961025,"value_label":"coordinate term","input_highlight":[4]},{"phase":1,"caption":"Compute coordinate 8: Combine KL terms in both directions","panel":{"kind":"bars","title":"Combine KL terms in both directions","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.04485514113604762,0.03783496427295624,0.01891748213647812],"a_label":"contribution","marker":7},"value":0.01891748213647812,"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":[2.6606919028236338e-05,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":0},"value":2.6606919028236338e-05,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 2 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[2.6606919028236338e-05,0.013967424746241033,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":1},"value":0.013994031665269269,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 3 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":2},"value":0.08165447292151773,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 4 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":3},"value":0.1235567471602408,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 5 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.0,0.0,0.0],"a_label":"contribution","marker":4},"value":0.13520222527320183,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 6 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.04485514113604762,0.0,0.0],"a_label":"contribution","marker":5},"value":0.18005736640924946,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 7 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.04485514113604762,0.03783496427295624,0.0],"a_label":"contribution","marker":6},"value":0.2178923306822057,"value_label":"running sum"},{"phase":2,"caption":"Accumulate 8 of 8 coordinate terms","panel":{"kind":"bars","title":"Terms included so far","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.04485514113604762,0.03783496427295624,0.01891748213647812],"a_label":"contribution","marker":7},"value":0.2368098128186838,"value_label":"running sum"},{"phase":3,"caption":"Sum the symmetric log-ratio contributions","panel":{"kind":"bars","title":"Combine KL terms in both directions","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.04485514113604762,0.03783496427295624,0.01891748213647812],"a_label":"contribution","marker":0},"value":0.2368098128186838,"value_label":"final result"},{"phase":3,"caption":"Sum the symmetric log-ratio contributions","panel":{"kind":"bars","title":"Combine KL terms in both directions","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.04485514113604762,0.03783496427295624,0.01891748213647812],"a_label":"contribution","marker":2},"value":0.2368098128186838,"value_label":"final result"},{"phase":3,"caption":"Sum the symmetric log-ratio contributions","panel":{"kind":"bars","title":"Combine KL terms in both directions","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.04485514113604762,0.03783496427295624,0.01891748213647812],"a_label":"contribution","marker":4},"value":0.2368098128186838,"value_label":"final result"},{"phase":3,"caption":"Sum the symmetric log-ratio contributions","panel":{"kind":"bars","title":"Combine KL terms in both directions","a":[2.6606919028236338e-05,0.013967424746241033,0.06766044125624845,0.04190227423872307,0.011645478112961025,0.04485514113604762,0.03783496427295624,0.01891748213647812],"a_label":"contribution","marker":7},"value":0.2368098128186838,"value_label":"final result"}],"animation_steps_en":["Normalize counts on one shared bin support.","Combine KL terms in both directions.","Accumulate the displayed bin contributions.","Sum the symmetric log-ratio contributions."],"echotime_status":"Low-priority addition","echotime_api":""}
