Last active
May 3, 2020 09:04
-
-
Save dboyliao/6a6fa5f3d547df60f13ed445f7b09a29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from itertools import combinations | |
def distance_loop(X): | |
N, M = X.shape | |
dist = np.zeros((N, N)) | |
for i, j in combinations(range(N), 2): | |
xi = X[i] | |
xj = X[j] | |
dist[i, j] = dist[j, i] = ((xi - xj) ** 2).sum() | |
return dist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment