{"id":"linear_trend_model_distance","title":"Linear-trend model distance","family":"model-based","definition":"echotime","intro_en":"Fit an ordinary least-squares line to each series on the sample-index axis. Compare the intercept, slope and population standard deviation of residuals. This is EchoTime's three-coordinate trend description; it retains overall direction and unexplained variation while compressing local structure. Euclidean distance retains differences in both vector scale and coordinates.","intro_zh":"以样本索引为时间轴，对每条序列拟合普通最小二乘直线，再比较截距、斜率和残差的总体标准差。这是 EchoTime 的三坐标趋势描述，保留总体方向与未解释波动，同时压缩局部结构。 欧氏距离同时保留向量尺度与坐标差异。","steps_en":["Fit x_t = intercept + slope*t and append the residual population SD.","Collect the computed coordinates in the same fixed order for both inputs.","Take the Euclidean norm of the coordinate differences.","Interpret the score in this representation, accounting for the information it discards."],"steps_zh":["拟合 x_t = 截距 + 斜率*t，并加入残差总体标准差。","把计算得到的坐标按同一个固定顺序组成两个向量。","对坐标差计算欧氏范数。","结合表示所舍弃的信息，在该表示空间中解释分数。"],"animation_steps_en":["Fit a line; retain intercept, slope and residual population SD.","Collect matching coordinates in the same vector order.","Take the Euclidean norm of coordinate differences.","Read the score in this feature space, with its stated information loss."],"formula":"d(x,y) = sqrt(sum_j (phi_j(x)-phi_j(y))^2)","caveats_en":["The slope uses sample index, so changing the sampling interval changes its interpretation; physical-time comparisons require consistent units.","Intercept, slope and residual SD have different scales. Curved trends and different residual patterns can share the same vector.","A metric on these feature vectors can be only a pseudometric on the original series when the representation loses information."],"caveats_zh":["斜率使用样本索引，改变采样间隔会改变其含义；按物理时间比较需要统一单位。","截距、斜率与残差标准差尺度不同；弯曲趋势或不同残差结构可能共享同一向量。","当表示损失信息时，特征空间中的度量在原序列空间上可能只是伪度量。"],"sources":[{"label":"EchoTime low-level implementation","url":"https://github.com/ZipengWu365/EchoTime/blob/main/src/echotime/similarity_methods.py"},{"label":"Exact illustrative inputs and encoder definitions","url":"https://github.com/ZipengWu365/EchoTime/blob/main/tools/method_animation_data/feature_model_embedding.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],"input_label":"Deterministic synthetic teaching signals, 16 samples each","parameters":{"time_axis":"sample index 0..15","fit":"ordinary least squares","residual_std_ddof":0,"features":["intercept","slope","residual_std"],"comparison":"euclidean"},"result":{"label":"distance","value":0.11805667833994533,"detail":"Computed from the explicitly defined illustrative encoder; no learned weights."},"frames":[{"phase":0,"caption":"Fit a straight line to the first 4 samples; retain residual variation.","panel":{"kind":"lines","title":"Least-squares trends on first 4 samples","a":[0.2744368972633516,0.5036110001104148,0.7327851029574781,0.9619592058045412],"a_label":"x fitted","b":[-0.21019805153394627,0.189933982822018,0.5900660171779823,0.9901980515339466],"b_label":"y fitted"},"input_highlight":[0,1,2,3]},{"phase":0,"caption":"Fit a straight line to the first 6 samples; retain residual variation.","panel":{"kind":"lines","title":"Least-squares trends on first 6 samples","a":[0.6929856655212363,0.5682178061839347,0.4434499468466331,0.3186820875093315,0.1939142281720299,0.06914636883472836],"a_label":"x fitted","b":[0.08750901898907723,0.24486075045277364,0.4022124819164701,0.5595642133801665,0.7169159448438629,0.8742676763075593],"b_label":"y fitted"},"input_highlight":[0,1,2,3,4,5]},{"phase":0,"caption":"Fit a straight line to the first 8 samples; retain residual variation.","panel":{"kind":"lines","title":"Least-squares trends on first 8 samples","a":[0.7242640687119283,0.5741359629668266,0.4240078572217248,0.273879751476623,0.12375164573152131,-0.026376460013580405,-0.17650456575868223,-0.32663267150378383],"a_label":"x fitted","b":[0.4599999999999999,0.40642857142857136,0.35285714285714276,0.29928571428571416,0.2457142857142856,0.192142857142857,0.13857142857142846,0.08499999999999991],"b_label":"y fitted"},"input_highlight":[0,1,2,3,4,5,6,7]},{"phase":0,"caption":"Fit a straight line to the first 10 samples; retain residual variation.","panel":{"kind":"lines","title":"Least-squares trends on first 10 samples","a":[0.4126739627014448,0.38511077328041016,0.3575475838593756,0.32998439443834093,0.30242120501730635,0.2748580155962717,0.2472948261752371,0.2197316367542025,0.19216844733316787,0.16460525791213326],"a_label":"x fitted","b":[0.38475728053544594,0.35980388295223764,0.3348504853690294,0.3098970877858211,0.2849436902026128,0.25999029261940454,0.23503689503619624,0.21008349745298793,0.18513009986977966,0.16017670228657138],"b_label":"y fitted"},"input_highlight":[0,1,2,3,4,5,6,7,8,9]},{"phase":0,"caption":"Fit a straight line to the first 12 samples; retain residual variation.","panel":{"kind":"lines","title":"Least-squares trends on first 12 samples","a":[0.16859318072653615,0.2208609691722536,0.273128757617971,0.32539654606368845,0.3776643345094059,0.4299321229551233,0.48219991140084073,0.5344676998465582,0.5867354882922756,0.6390032767379931,0.6912710651837105,0.743538853629428],"a_label":"x fitted","b":[0.16997460877769927,0.21270649809084483,0.2554383874039904,0.2981702767171359,0.3409021660302815,0.3836340553434271,0.4263659446565726,0.4690978339697182,0.5118297232828637,0.5545616125960093,0.5972935019091549,0.6400253912223004],"b_label":"y fitted"},"input_highlight":[0,1,2,3,4,5,6,7,8,9,10,11]},{"phase":0,"caption":"Fit a straight line to the first 16 samples; retain residual variation.","panel":{"kind":"lines","title":"Least-squares trends on first 16 samples","a":[0.4044477704393201,0.4005214010474108,0.3965950316555014,0.3926686622635921,0.38874229287168277,0.38481592347977345,0.38088955408786407,0.37696318469595474,0.3730368153040454,0.3691104459121361,0.3651840765202267,0.3612577071283174,0.3573313377364081,0.35340496834449875,0.34947859895258937,0.34555222956068005],"a_label":"x fitted","b":[0.3141176470588237,0.32723529411764724,0.34035294117647075,0.3534705882352943,0.3665882352941178,0.37970588235294134,0.39282352941176485,0.40594117647058836,0.41905882352941193,0.43217647058823544,0.44529411764705895,0.45841176470588246,0.471529411764706,0.48464705882352954,0.497764705882353,0.5108823529411766],"b_label":"y fitted"},"input_highlight":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]},{"phase":1,"caption":"Expose 1 of 3 coordinates; each has the same meaning in x and y.","panel":{"kind":"bars","title":"Feature vectors","a":[0.4044477704393201],"a_label":"x features","b":[0.3141176470588237],"b_label":"y features","labels":["intercept"],"marker":0}},{"phase":1,"caption":"Expose 1 of 3 coordinates; each has the same meaning in x and y.","panel":{"kind":"bars","title":"Feature vectors","a":[0.4044477704393201],"a_label":"x features","b":[0.3141176470588237],"b_label":"y features","labels":["intercept"],"marker":0}},{"phase":1,"caption":"Expose 1 of 3 coordinates; each has the same meaning in x and y.","panel":{"kind":"bars","title":"Feature vectors","a":[0.4044477704393201],"a_label":"x features","b":[0.3141176470588237],"b_label":"y features","labels":["intercept"],"marker":0}},{"phase":1,"caption":"Expose 2 of 3 coordinates; each has the same meaning in x and y.","panel":{"kind":"bars","title":"Feature vectors","a":[0.4044477704393201,-0.003926369391909338],"a_label":"x features","b":[0.3141176470588237,0.013117647058823522],"b_label":"y features","labels":["intercept","slope"],"marker":1}},{"phase":1,"caption":"Expose 2 of 3 coordinates; each has the same meaning in x and y.","panel":{"kind":"bars","title":"Feature vectors","a":[0.4044477704393201,-0.003926369391909338],"a_label":"x features","b":[0.3141176470588237,0.013117647058823522],"b_label":"y features","labels":["intercept","slope"],"marker":1}},{"phase":1,"caption":"Expose 3 of 3 coordinates; each has the same meaning in x and y.","panel":{"kind":"bars","title":"Feature vectors","a":[0.4044477704393201,-0.003926369391909338,0.6100567826027345],"a_label":"x features","b":[0.3141176470588237,0.013117647058823522,0.5359801357161971],"b_label":"y features","labels":["intercept","slope","resid SD"],"marker":2}},{"phase":2,"caption":"Accumulate squared differences, then take the square root.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702],"a_label":"contributions","labels":["intercept"],"marker":0},"value":0.0903301233804964,"value_label":"partial distance"},{"phase":2,"caption":"Accumulate squared differences, then take the square root.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702],"a_label":"contributions","labels":["intercept"],"marker":0},"value":0.0903301233804964,"value_label":"partial distance"},{"phase":2,"caption":"Accumulate squared differences, then take the square root.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702],"a_label":"contributions","labels":["intercept"],"marker":0},"value":0.0903301233804964,"value_label":"partial distance"},{"phase":2,"caption":"Accumulate squared differences, then take the square root.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702,0.00029049849677285233],"a_label":"contributions","labels":["intercept","slope"],"marker":1},"value":0.0919240430285165,"value_label":"partial distance"},{"phase":2,"caption":"Accumulate squared differences, then take the square root.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702,0.00029049849677285233],"a_label":"contributions","labels":["intercept","slope"],"marker":1},"value":0.0919240430285165,"value_label":"partial distance"},{"phase":2,"caption":"Accumulate squared differences, then take the square root.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702,0.00029049849677285233,0.005487349613952763],"a_label":"contributions","labels":["intercept","slope","resid SD"],"marker":2},"value":0.11805667833994533,"value_label":"partial distance"},{"phase":3,"caption":"Read the completed comparison using every retained coordinate.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702,0.00029049849677285233,0.005487349613952763],"a_label":"contributions","labels":["intercept","slope","resid SD"],"marker":0},"value":0.11805667833994533,"value_label":"final distance"},{"phase":3,"caption":"Read the completed comparison using every retained coordinate.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702,0.00029049849677285233,0.005487349613952763],"a_label":"contributions","labels":["intercept","slope","resid SD"],"marker":1},"value":0.11805667833994533,"value_label":"final distance"},{"phase":3,"caption":"Read the completed comparison using every retained coordinate.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702,0.00029049849677285233,0.005487349613952763],"a_label":"contributions","labels":["intercept","slope","resid SD"],"marker":2},"value":0.11805667833994533,"value_label":"final distance"},{"phase":3,"caption":"Read the completed comparison using every retained coordinate.","panel":{"kind":"bars","title":"Squared coordinate differences","a":[0.008159531189935702,0.00029049849677285233,0.005487349613952763],"a_label":"contributions","labels":["intercept","slope","resid SD"],"marker":2},"value":0.11805667833994533,"value_label":"final distance"}],"checks":{"api":"echotime.linear_trend_model_distance","expected":0.11805667833994533,"observed":0.11805667833994533,"tolerance":1e-10},"echotime_status":"Implemented in EchoTime","echotime_api":"linear_trend_model_distance"}
