I am assuming you are looking for something that broadcasts the kendalltau
function over each of the 3 arrays and permutes over them. The output in that case will be a 3x3
matrix. I am not sure of what you are looking for when you say you want the variance, however. Do clarify in the comments and I'll update my answer accordingly. Hope this helps -
a = np.array([[1,2,3,4,5,6], [2,3,4,6,1,5], [6,3,1,2,5,4]])
def f(a,b):
return np.array(stats.kendalltau(a,b)[0])
vf = np.vectorize(f, signature='(m),(m)->()')
out = vf(a[:,None,:],a[None,:,:])
print(out)
array([[ 1. , 0.33333333, -0.06666667],
[ 0.33333333, 1. , -0.46666667],
[-0.06666667, -0.46666667, 1. ]])
So, how to compute (in Python) the variance on this array, i.e, how to measure how far theses permutations are from each other ?
IIUC, if you are trying to calculate the kendalltau
distances between each of the combinations and then check the standard deviation between the distances, you can filter our the lower triangular matrix (without diagonal) using np.tril_indices(k=-1)
and then fetch the 3 values to take a np.std
np.std(out[np.tril_indices(out.shape[0], k=-1)])
0.3265986323710904