{"id":"spearman_similarity","title":"Spearman rank correlation","family":"lock-step","definition":"reference","intro_en":"Spearman correlation replaces amplitudes by their ranks and then computes Pearson correlation of those ranks. Tied observations receive average ranks in this example. The animation makes this change of representation explicit: a monotone nonlinear amplitude transformation can retain rank agreement even when the raw scatter is not a straight line.","intro_zh":"Spearman 相关先把幅值转换成排名，再计算排名的 Pearson 相关。本例对并列值使用平均排名。动图显式展示表示变换：单调非线性幅值变换即使改变原始散点的线性关系，仍可能保留排名一致性。","steps_en":["Pair observations and retain their original sample identities.","Replace amplitudes with average ranks, including ties.","Compute Pearson correlation of the two rank vectors.","Read the signed agreement coefficient."],"steps_zh":["配对观测并保留原始采样身份。","将幅值替换为含并列处理的平均排名。","计算两组排名的 Pearson 相关。","读取排名相关或其 1 减变换。"],"formula":"corr(rank_average(x),rank_average(y))","caveats_en":["Amplitude differences are intentionally discarded by ranking.","A nonmonotone dependence may be strong while Spearman correlation is weak.","The chosen tie rule and missing-value handling belong to the definition."],"caveats_zh":["排名主动舍弃幅值差异。","强非单调依赖也可能具有很弱的 Spearman 相关。","并列排名和缺失值处理属于定义的一部分。"],"sources":[{"label":"SciPy: spearmanr","url":"https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.spearmanr.html"}],"x":[1.0,2.0,2.0,4.0,3.0,5.0,5.0,7.0,8.0,6.0,9.0,10.0],"y":[1.0,1.8,2.2,3.4,2.7,4.1,4.1,6.4,6.1,5.5,8.0,9.2],"input_label":"Deterministic synthetic illustration; sample index is the time axis.","parameters":{"centering":true,"ranking":true,"tie_rule":"average rank or tau-b correction"},"result":{"label":"similarity","value":0.9912141845604474,"detail":""},"frames":[{"phase":0,"caption":"Compare paired observations on the same time grid","panel":{"kind":"scatter","title":"Paired observations: x versus y","a":[1.0,2.0,2.0],"b":[1.0,1.8,2.2],"marker":2}},{"phase":0,"caption":"Compare paired observations on the same time grid","panel":{"kind":"scatter","title":"Paired observations: x versus y","a":[1.0,2.0,2.0,4.0,3.0,5.0],"b":[1.0,1.8,2.2,3.4,2.7,4.1],"marker":5}},{"phase":0,"caption":"Compare paired observations on the same time grid","panel":{"kind":"scatter","title":"Paired observations: x versus y","a":[1.0,2.0,2.0,4.0,3.0,5.0,5.0,7.0,8.0],"b":[1.0,1.8,2.2,3.4,2.7,4.1,4.1,6.4,6.1],"marker":8}},{"phase":0,"caption":"Compare paired observations on the same time grid","panel":{"kind":"scatter","title":"Paired observations: x versus y","a":[1.0,2.0,2.0,4.0,3.0,5.0,5.0,7.0,8.0,6.0,9.0,10.0],"b":[1.0,1.8,2.2,3.4,2.7,4.1,4.1,6.4,6.1,5.5,8.0,9.2],"marker":11}},{"phase":1,"caption":"Average ranks, then center","panel":{"kind":"lines","title":"Centered ranks","a":[-5.5,-4.0,-4.0],"a_label":"x","b":[-5.5,-4.5,-3.5],"b_label":"y"}},{"phase":1,"caption":"Average ranks, then center","panel":{"kind":"lines","title":"Centered ranks","a":[-5.5,-4.0,-4.0,-1.5,-2.5,0.0],"a_label":"x","b":[-5.5,-4.5,-3.5,-1.5,-2.5,0.0],"b_label":"y"}},{"phase":1,"caption":"Average ranks, then center","panel":{"kind":"lines","title":"Centered ranks","a":[-5.5,-4.0,-4.0,-1.5,-2.5,0.0,0.0,2.5,3.5],"a_label":"x","b":[-5.5,-4.5,-3.5,-1.5,-2.5,0.0,0.0,3.5,2.5],"b_label":"y"}},{"phase":1,"caption":"Average ranks, then center","panel":{"kind":"lines","title":"Centered ranks","a":[-5.5,-4.0,-4.0,-1.5,-2.5,0.0,0.0,2.5,3.5,1.5,4.5,5.5],"a_label":"x","b":[-5.5,-4.5,-3.5,-1.5,-2.5,0.0,0.0,3.5,2.5,1.5,4.5,5.5],"b_label":"y"}},{"phase":2,"caption":"Accumulate normalized products using fixed full-vector norms","panel":{"kind":"bars","title":"Contribution to normalized dot product","a":[0.21265410697130166,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":0},"value":0.21265410697130166,"value_label":"partial normalized dot product"},{"phase":2,"caption":"Accumulate normalized products using fixed full-vector norms","panel":{"kind":"bars","title":"Contribution to normalized dot product","a":[0.21265410697130166,0.12653798100771668,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":1},"value":0.33919208797901834,"value_label":"partial normalized dot product"},{"phase":2,"caption":"Accumulate normalized products using fixed full-vector norms","panel":{"kind":"bars","title":"Contribution to normalized dot product","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":3},"value":0.4534277652776515,"value_label":"partial normalized dot product"},{"phase":2,"caption":"Accumulate normalized products using fixed full-vector norms","panel":{"kind":"bars","title":"Contribution to normalized dot product","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":4},"value":0.49736456423866426,"value_label":"partial normalized dot product"},{"phase":2,"caption":"Accumulate normalized products using fixed full-vector norms","panel":{"kind":"bars","title":"Contribution to normalized dot product","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":6},"value":0.49736456423866426,"value_label":"partial normalized dot product"},{"phase":2,"caption":"Accumulate normalized products using fixed full-vector norms","panel":{"kind":"bars","title":"Contribution to normalized dot product","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.06151151854541783,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":7},"value":0.5588760827840821,"value_label":"partial normalized dot product"},{"phase":2,"caption":"Accumulate normalized products using fixed full-vector norms","panel":{"kind":"bars","title":"Contribution to normalized dot product","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.06151151854541783,0.06151151854541783,0.015817247625964585,0.0,0.0],"a_label":"contribution","marker":9},"value":0.6362048489554645,"value_label":"partial normalized dot product"},{"phase":2,"caption":"Accumulate normalized products using fixed full-vector norms","panel":{"kind":"bars","title":"Contribution to normalized dot product","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.06151151854541783,0.06151151854541783,0.015817247625964585,0.14235522863368127,0.21265410697130166],"a_label":"contribution","marker":11},"value":0.9912141845604474,"value_label":"partial normalized dot product"},{"phase":3,"caption":"Read the signed agreement coefficient","panel":{"kind":"bars","title":"All normalized coordinate products","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.06151151854541783,0.06151151854541783,0.015817247625964585,0.14235522863368127,0.21265410697130166],"a_label":"contribution","marker":0},"value":0.9912141845604474,"value_label":"final result"},{"phase":3,"caption":"Read the signed agreement coefficient","panel":{"kind":"bars","title":"All normalized coordinate products","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.06151151854541783,0.06151151854541783,0.015817247625964585,0.14235522863368127,0.21265410697130166],"a_label":"contribution","marker":3},"value":0.9912141845604474,"value_label":"final result"},{"phase":3,"caption":"Read the signed agreement coefficient","panel":{"kind":"bars","title":"All normalized coordinate products","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.06151151854541783,0.06151151854541783,0.015817247625964585,0.14235522863368127,0.21265410697130166],"a_label":"contribution","marker":7},"value":0.9912141845604474,"value_label":"final result"},{"phase":3,"caption":"Read the signed agreement coefficient","panel":{"kind":"bars","title":"All normalized coordinate products","a":[0.21265410697130166,0.12653798100771668,0.09841842967266853,0.015817247625964585,0.04393679896101274,0.0,0.0,0.06151151854541783,0.06151151854541783,0.015817247625964585,0.14235522863368127,0.21265410697130166],"a_label":"contribution","marker":11},"value":0.9912141845604474,"value_label":"final result"}],"animation_steps_en":["Pair observations and retain sample identities.","Assign average ranks, including ties.","Compute Pearson correlation of rank vectors.","Keep the signed rank correlation."],"echotime_status":"Conceptually covered","echotime_api":"spearman_rho"}
