{"id":"ordinal_pattern_js_distance","title":"Ordinal-pattern JS distance","family":"feature-based","definition":"echotime","intro_en":"Turn every three-observation window into its ordering pattern, then compare the six-pattern probability vectors with square-root Jensen-Shannon divergence. This retains which patterns are frequent and follows EchoTime's natural-log definition.","intro_zh":"把每个三点窗口转换成排序模式，再以 Jensen-Shannon 散度的平方根比较六种模式的概率向量。它保留具体哪些模式更常出现，并遵循 EchoTime 使用自然对数的定义。","steps_en":["Form overlapping windows with order 3 and delay 1.","Stably rank each window and count all six possible permutations.","Compute square-root Jensen-Shannon divergence with natural logarithms.","Read a distribution distance and check the chosen order/delay."],"steps_zh":["使用阶数 3、延迟 1 构造重叠窗口。","稳定排序各窗口，并统计全部六种排列。","使用自然对数计算 Jensen-Shannon 散度的平方根。","读取分布距离，并检查所选阶数与延迟。"],"formula":"d = sqrt((KL(p||m)+KL(q||m))/2), m=(p+q)/2","caveats_en":["Order 3, delay 1 and stable tie-breaking by earlier position are explicit choices; frequent ties can change the interpretation.","Short sequences provide sparse pattern counts; overlapping windows are not independent samples.","Pattern frequencies discard when patterns occur."],"caveats_zh":["阶数 3、延迟 1，以及按较早位置优先的稳定并列处理都是明确选择；大量并列值会改变解释。","短序列的模式统计稀疏，重叠窗口也不是独立样本。","模式频率舍弃模式出现的具体时刻。"],"sources":[{"label":"Bandt and Pompe (2002), permutation entropy","url":"https://doi.org/10.1103/PhysRevLett.88.174102"},{"label":"SciPy: square-root Jensen-Shannon divergence","url":"https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.jensenshannon.html"},{"label":"EchoTime low-level implementation","url":"https://github.com/ZipengWu365/EchoTime/blob/main/src/echotime/similarity_methods.py"}],"x":[0.0,0.8769216919004693,0.8094744111674236,0.7863961030678929,0.3905255888325767,-0.5769216919004693,-0.6000000000000001,-0.09587051423531628,0.2094744111674235,1.0863961030678926,1.5905255888325764,0.9958705142353173,0.6000000000000002,0.20412948576468337,-0.39052558883257615,0.11360389693210537],"y":[-0.2003300858899106,0.185,0.5703300858899106,1.005,1.0003300858899107,0.3250000000000002,-0.35033008588991066,-0.3550000000000001,0.07966991411008931,0.46499999999999997,0.8503300858899105,1.2849999999999995,1.2803300858899114,0.6050000000000002,-0.07033008588991083,-0.07500000000000043],"parameters":{"order":3,"delay":1,"tie_policy":"stable by index","log_base":"e","entropy_normalized":false},"result":{"label":"distance","value":0.25686047464429757,"detail":"Natural-log JS distance"},"frames":[{"phase":0,"caption":"Rank each length-three window; 1 windows counted so far.","panel":{"kind":"bars","title":"Observed ordinal-pattern proportions","a":[0.0,1.0,0.0,0.0,0.0,0.0],"a_label":"x pattern mass","b":[1.0,0.0,0.0,0.0,0.0,0.0],"b_label":"y pattern mass","labels":["012","021","102","120","201","210"],"marker":1},"input_highlight":[0,1,2]},{"phase":0,"caption":"Rank each length-three window; 3 windows counted so far.","panel":{"kind":"bars","title":"Observed ordinal-pattern proportions","a":[0.0,0.3333333333333333,0.0,0.0,0.0,0.6666666666666666],"a_label":"x pattern mass","b":[0.6666666666666666,0.3333333333333333,0.0,0.0,0.0,0.0],"b_label":"y pattern mass","labels":["012","021","102","120","201","210"],"marker":5},"input_highlight":[2,3,4]},{"phase":0,"caption":"Rank each length-three window; 5 windows counted so far.","panel":{"kind":"bars","title":"Observed ordinal-pattern proportions","a":[0.0,0.2,0.0,0.0,0.0,0.8],"a_label":"x pattern mass","b":[0.4,0.2,0.0,0.0,0.0,0.4],"b_label":"y pattern mass","labels":["012","021","102","120","201","210"],"marker":5},"input_highlight":[4,5,6]},{"phase":0,"caption":"Rank each length-three window; 8 windows counted so far.","panel":{"kind":"bars","title":"Observed ordinal-pattern proportions","a":[0.25,0.125,0.125,0.0,0.0,0.5],"a_label":"x pattern mass","b":[0.375,0.125,0.125,0.0,0.0,0.375],"b_label":"y pattern mass","labels":["012","021","102","120","201","210"],"marker":0},"input_highlight":[7,8,9]},{"phase":0,"caption":"Rank each length-three window; 11 windows counted so far.","panel":{"kind":"bars","title":"Observed ordinal-pattern proportions","a":[0.2727272727272727,0.09090909090909091,0.09090909090909091,0.0,0.09090909090909091,0.45454545454545453],"a_label":"x pattern mass","b":[0.45454545454545453,0.18181818181818182,0.09090909090909091,0.0,0.0,0.2727272727272727],"b_label":"y pattern mass","labels":["012","021","102","120","201","210"],"marker":5},"input_highlight":[10,11,12]},{"phase":0,"caption":"Rank each length-three window; 14 windows counted so far.","panel":{"kind":"bars","title":"Observed ordinal-pattern proportions","a":[0.21428571428571427,0.07142857142857142,0.07142857142857142,0.07142857142857142,0.07142857142857142,0.5],"a_label":"x pattern mass","b":[0.35714285714285715,0.14285714285714285,0.07142857142857142,0.0,0.0,0.42857142857142855],"b_label":"y pattern mass","labels":["012","021","102","120","201","210"],"marker":3},"input_highlight":[13,14,15]},{"phase":1,"caption":"Keep the full six-pattern distribution, including patterns with zero count.","panel":{"kind":"bars","title":"Final ordinal-pattern distributions","a":[0.21428571428571427],"a_label":"x features","b":[0.35714285714285715],"b_label":"y features","labels":["012"],"marker":0}},{"phase":1,"caption":"Keep the full six-pattern distribution, including patterns with zero count.","panel":{"kind":"bars","title":"Final ordinal-pattern distributions","a":[0.21428571428571427,0.07142857142857142],"a_label":"x features","b":[0.35714285714285715,0.14285714285714285],"b_label":"y features","labels":["012","021"],"marker":1}},{"phase":1,"caption":"Keep the full six-pattern distribution, including patterns with zero count.","panel":{"kind":"bars","title":"Final ordinal-pattern distributions","a":[0.21428571428571427,0.07142857142857142,0.07142857142857142],"a_label":"x features","b":[0.35714285714285715,0.14285714285714285,0.07142857142857142],"b_label":"y features","labels":["012","021","102"],"marker":2}},{"phase":1,"caption":"Keep the full six-pattern distribution, including patterns with zero count.","panel":{"kind":"bars","title":"Final ordinal-pattern distributions","a":[0.21428571428571427,0.07142857142857142,0.07142857142857142,0.07142857142857142],"a_label":"x features","b":[0.35714285714285715,0.14285714285714285,0.07142857142857142,0.0],"b_label":"y features","labels":["012","021","102","120"],"marker":3}},{"phase":1,"caption":"Keep the full six-pattern distribution, including patterns with zero count.","panel":{"kind":"bars","title":"Final ordinal-pattern distributions","a":[0.21428571428571427,0.07142857142857142,0.07142857142857142,0.07142857142857142,0.07142857142857142],"a_label":"x features","b":[0.35714285714285715,0.14285714285714285,0.07142857142857142,0.0,0.0],"b_label":"y features","labels":["012","021","102","120","201"],"marker":4}},{"phase":1,"caption":"Keep the full six-pattern distribution, including patterns with zero count.","panel":{"kind":"bars","title":"Final ordinal-pattern distributions","a":[0.21428571428571427,0.07142857142857142,0.07142857142857142,0.07142857142857142,0.07142857142857142,0.5],"a_label":"x features","b":[0.35714285714285715,0.14285714285714285,0.07142857142857142,0.0,0.0,0.42857142857142855],"b_label":"y features","labels":["012","021","102","120","201","210"],"marker":5}},{"phase":2,"caption":"Accumulate the stated distribution functional; zero-mass terms contribute zero.","panel":{"kind":"bars","title":"Per-pattern Jensen-Shannon contributions","a":[0.00902398354341808],"a_label":"JS contributions","labels":["012"],"marker":0},"value":0.09499465007787586,"value_label":"partial JS distance"},{"phase":2,"caption":"Accumulate the stated distribution functional; zero-mass terms contribute zero.","panel":{"kind":"bars","title":"Per-pattern Jensen-Shannon contributions","a":[0.00902398354341808,0.006067822742692757],"a_label":"JS contributions","labels":["012","021"],"marker":1},"value":0.1228487130014427,"value_label":"partial JS distance"},{"phase":2,"caption":"Accumulate the stated distribution functional; zero-mass terms contribute zero.","panel":{"kind":"bars","title":"Per-pattern Jensen-Shannon contributions","a":[0.00902398354341808,0.006067822742692757,0.0],"a_label":"JS contributions","labels":["012","021","102"],"marker":2},"value":0.1228487130014427,"value_label":"partial JS distance"},{"phase":2,"caption":"Accumulate the stated distribution functional; zero-mass terms contribute zero.","panel":{"kind":"bars","title":"Per-pattern Jensen-Shannon contributions","a":[0.00902398354341808,0.006067822742692757,0.0,0.024755256448569473],"a_label":"JS contributions","labels":["012","021","102","120"],"marker":3},"value":0.1996172906706238,"value_label":"partial JS distance"},{"phase":2,"caption":"Accumulate the stated distribution functional; zero-mass terms contribute zero.","panel":{"kind":"bars","title":"Per-pattern Jensen-Shannon contributions","a":[0.00902398354341808,0.006067822742692757,0.0,0.024755256448569473,0.024755256448569473],"a_label":"JS contributions","labels":["012","021","102","120","201"],"marker":4},"value":0.2541698628540563,"value_label":"partial JS distance"},{"phase":2,"caption":"Accumulate the stated distribution functional; zero-mass terms contribute zero.","panel":{"kind":"bars","title":"Per-pattern Jensen-Shannon contributions","a":[0.00902398354341808,0.006067822742692757,0.0,0.024755256448569473,0.024755256448569473,0.0013749842512440665],"a_label":"JS contributions","labels":["012","021","102","120","201","210"],"marker":5},"value":0.25686047464429757,"value_label":"partial JS distance"},{"phase":3,"caption":"Compare full pattern distributions.","panel":{"kind":"bars","title":"JS terms; take square root of their sum","a":[0.00902398354341808,0.006067822742692757,0.0,0.024755256448569473,0.024755256448569473,0.0013749842512440665],"a_label":"JS contributions","labels":["012","021","102","120","201","210"],"marker":0},"value":0.25686047464429757,"value_label":"final distance"},{"phase":3,"caption":"Compare full pattern distributions.","panel":{"kind":"bars","title":"JS terms; take square root of their sum","a":[0.00902398354341808,0.006067822742692757,0.0,0.024755256448569473,0.024755256448569473,0.0013749842512440665],"a_label":"JS contributions","labels":["012","021","102","120","201","210"],"marker":1},"value":0.25686047464429757,"value_label":"final distance"},{"phase":3,"caption":"Compare full pattern distributions.","panel":{"kind":"bars","title":"JS terms; take square root of their sum","a":[0.00902398354341808,0.006067822742692757,0.0,0.024755256448569473,0.024755256448569473,0.0013749842512440665],"a_label":"JS contributions","labels":["012","021","102","120","201","210"],"marker":2},"value":0.25686047464429757,"value_label":"final distance"},{"phase":3,"caption":"Compare full pattern distributions.","panel":{"kind":"bars","title":"JS terms; take square root of their sum","a":[0.00902398354341808,0.006067822742692757,0.0,0.024755256448569473,0.024755256448569473,0.0013749842512440665],"a_label":"JS contributions","labels":["012","021","102","120","201","210"],"marker":3},"value":0.25686047464429757,"value_label":"final distance"}],"animation_steps_en":["Form overlapping three-point windows with delay one.","Rank each window; count all six patterns with a fixed tie policy.","Compare the full distributions with natural-log Jensen-Shannon divergence.","Take the square root to obtain the displayed JS distance."],"checks":{"api":"echotime.ordinal_pattern_js_distance","expected":0.25686047464429757,"observed":0.25686047464429773,"tolerance":1e-10},"echotime_status":"Implemented in EchoTime","echotime_api":"ordinal_pattern_js_distance"}
