Condensed matrix function to find pairs

后端 未结 7 1159
忘了有多久
忘了有多久 2020-12-24 05:18

For a set of observations:

[a1,a2,a3,a4,a5]

their pairwise distances

d=[[0,a12,a13,a14,a15]
   [a21,0,a23,a24,a25]
   [a31,         


        
7条回答
  •  孤城傲影
    2020-12-24 05:49

    Here's another solution:

    import numpy as np
    
    def f(c,n):
        tt = np.zeros_like(c)
        tt[n] = 1
        return tuple(np.nonzero(squareform(tt))[0])
    

提交回复
热议问题