{"id":"shift_manhattan_distance","title":"Shifted Manhattan","family":"sliding","definition":"reference","intro_en":"Shifted Manhattan evaluates sum of absolute overlap errors after each permitted integer shift, using only samples that overlap. This example admits lags from minus three to plus three samples, leaving at least seven paired observations. The animation shows the actual overlap pairs and candidate scores before selecting their minimum.","intro_zh":"Shifted Manhattan 在每个允许的整数平移后，仅对重叠样本计算对应分数。本例滞后范围为 −3 至 +3 个采样点，始终保留至少七对观测。动图展示实际配对和候选分数，再选择最小值。","steps_en":["Fix the permitted lags and minimum acceptable overlap before scoring.","At each lag, compute sum of absolute overlap errors on the actual paired samples.","Record every candidate score together with its lag.","Choose the minimum overlap score."],"steps_zh":["先固定允许滞后与最小可接受重叠长度。","对每个滞后的实际配对样本计算对应分数。","记录所有候选分数及其滞后。","选取最小重叠分数。"],"formula":"min_{lag=-3,...,3} ||x_overlap-y_overlap||_1","caveats_en":["The unnormalized L1 total changes with overlap size; restrict admissible lags.","The bounded window is an explicit demonstration choice; allowing every possible lag changes the problem.","Overlap cropping removes unmatched endpoints from this score."],"caveats_zh":["未归一化 L1 总量随重叠数量变化，应限制允许的滞后。","有界窗口是明确的演示选择；允许所有滞后会改变问题。","重叠裁剪会从分数中排除未匹配的两端。"],"sources":[{"label":"Imported registry: overlap-based shift definitions","url":"https://github.com/ZipengWu365/EchoTime/blob/main/src/echotime/data/ts_similarity_package_v2_registry.csv"},{"label":"SciPy: cityblock","url":"https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cityblock.html"}],"x":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"y":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"input_label":"Deterministic synthetic illustration; sample index is the time axis.","parameters":{"lags":[-3,-2,-1,0,1,2,3],"minimum_overlap":7,"normalization":"none beyond stated mean/root","selected_lag":-2},"result":{"label":"distance","value":0.15312069100918346,"detail":""},"frames":[{"phase":0,"caption":"Use the declared bounded lag window: -3 to +3 samples","panel":{"kind":"lines","title":"Original input; no hidden standardization","a":[1.0,1.1,1.8],"a_label":"x","b":[1.0,1.025244129544237,1.0272789228047705],"b_label":"y"}},{"phase":0,"caption":"Use the declared bounded lag window: -3 to +3 samples","panel":{"kind":"lines","title":"Original input; no hidden standardization","a":[1.0,1.1,1.8,3.1,2.4],"a_label":"x","b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623],"b_label":"y"}},{"phase":0,"caption":"Use the declared bounded lag window: -3 to +3 samples","panel":{"kind":"lines","title":"Original input; no hidden standardization","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8],"a_label":"x","b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323],"b_label":"y"}},{"phase":0,"caption":"Use the declared bounded lag window: -3 to +3 samples","panel":{"kind":"lines","title":"Original input; no hidden standardization","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"a_label":"x","b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"b_label":"y"}},{"phase":1,"caption":"Lag -3: sum of absolute overlap errors","panel":{"kind":"alignment","title":"Overlap correspondence at lag -3","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[0,3],[1,4],[2,5],[3,6],[4,7],[5,8],[6,9]]},"value":4.42411747128562,"value_label":"current overlap score"},{"phase":1,"caption":"Lag -2: sum of absolute overlap errors","panel":{"kind":"alignment","title":"Overlap correspondence at lag -2","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[0,2],[1,3],[2,4],[3,5],[4,6],[5,7],[6,8],[7,9]]},"value":0.15312069100918346,"value_label":"current overlap score"},{"phase":1,"caption":"Lag -1: sum of absolute overlap errors","panel":{"kind":"alignment","title":"Overlap correspondence at lag -1","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9]]},"value":4.656950784176656,"value_label":"current overlap score"},{"phase":1,"caption":"Lag +0: sum of absolute overlap errors","panel":{"kind":"alignment","title":"Overlap correspondence at lag +0","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9]]},"value":7.606462525088182,"value_label":"current overlap score"},{"phase":1,"caption":"Lag +1: sum of absolute overlap errors","panel":{"kind":"alignment","title":"Overlap correspondence at lag +1","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[1,0],[2,1],[3,2],[4,3],[5,4],[6,5],[7,6],[8,7],[9,8]]},"value":8.873417929926958,"value_label":"current overlap score"},{"phase":1,"caption":"Lag +2: sum of absolute overlap errors","panel":{"kind":"alignment","title":"Overlap correspondence at lag +2","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[2,0],[3,1],[4,2],[5,3],[6,4],[7,5],[8,6],[9,7]]},"value":9.203098677325661,"value_label":"current overlap score"},{"phase":1,"caption":"Lag +3: sum of absolute overlap errors","panel":{"kind":"alignment","title":"Overlap correspondence at lag +3","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[3,0],[4,1],[5,2],[6,3],[7,4],[8,5],[9,6]]},"value":8.29185627984769,"value_label":"current overlap score"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[4.42411747128562],"a_label":"overlap score","marker":0,"x":[-3.0]},"value":4.42411747128562,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[4.42411747128562,0.15312069100918346],"a_label":"overlap score","marker":1,"x":[-3.0,-2.0]},"value":0.15312069100918346,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[4.42411747128562,0.15312069100918346,4.656950784176656],"a_label":"overlap score","marker":2,"x":[-3.0,-2.0,-1.0]},"value":0.15312069100918346,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[4.42411747128562,0.15312069100918346,4.656950784176656,7.606462525088182],"a_label":"overlap score","marker":3,"x":[-3.0,-2.0,-1.0,0.0]},"value":0.15312069100918346,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[4.42411747128562,0.15312069100918346,4.656950784176656,7.606462525088182,8.873417929926958],"a_label":"overlap score","marker":4,"x":[-3.0,-2.0,-1.0,0.0,1.0]},"value":0.15312069100918346,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[4.42411747128562,0.15312069100918346,4.656950784176656,7.606462525088182,8.873417929926958,9.203098677325661],"a_label":"overlap score","marker":5,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0]},"value":0.15312069100918346,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[4.42411747128562,0.15312069100918346,4.656950784176656,7.606462525088182,8.873417929926958,9.203098677325661,8.29185627984769],"a_label":"overlap score","marker":6,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.15312069100918346,"value_label":"best candidate so far"},{"phase":3,"caption":"Select the smallest overlap error","panel":{"kind":"lines","title":"Complete bounded lag scan","a":[4.42411747128562,0.15312069100918346,4.656950784176656,7.606462525088182,8.873417929926958,9.203098677325661,8.29185627984769],"a_label":"candidate score","marker":1,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.15312069100918346,"value_label":"final result"},{"phase":3,"caption":"Select the smallest overlap error","panel":{"kind":"lines","title":"Complete bounded lag scan","a":[4.42411747128562,0.15312069100918346,4.656950784176656,7.606462525088182,8.873417929926958,9.203098677325661,8.29185627984769],"a_label":"candidate score","marker":1,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.15312069100918346,"value_label":"final result"},{"phase":3,"caption":"Select the smallest overlap error","panel":{"kind":"lines","title":"Complete bounded lag scan","a":[4.42411747128562,0.15312069100918346,4.656950784176656,7.606462525088182,8.873417929926958,9.203098677325661,8.29185627984769],"a_label":"candidate score","marker":1,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.15312069100918346,"value_label":"final result"},{"phase":3,"caption":"Select the smallest overlap error","panel":{"kind":"lines","title":"Complete bounded lag scan","a":[4.42411747128562,0.15312069100918346,4.656950784176656,7.606462525088182,8.873417929926958,9.203098677325661,8.29185627984769],"a_label":"candidate score","marker":1,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.15312069100918346,"value_label":"final result"}],"animation_steps_en":["Fix lags from -3 to +3 and retain adequate overlap.","Compute L1 error on each actual overlap.","Record every candidate score with its lag.","Choose the minimum overlap error."],"echotime_status":"Possible addition","echotime_api":""}
