I need to calculate this special variance estimate (see pic. below). I have feature matrix X - dxl (d - # features, l - # objects). It's simply to do this in for cycles:
var_list = []
for i in range(X.shape[0]):
for j in range(i + 1, X.shape[0]):
var_list.append(((X[i, :] - X[j, :]) ** 2).sum())
variance = np.median(var_list)
But this is ineffective because of python cycle. Is there a way to do it by numpy faster?
Formula for variance: