Created
November 30, 2018 20:45
-
-
Save hyponymous/a7970b77bd5daf6ec6dfd14aba039a89 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import itertools | |
import numpy as np | |
N = 1000 | |
d = 500 | |
x_normal = np.random.multivariate_normal([0], [[1]], [N, d]).reshape([N, d]) | |
x_spherical = x_normal / np.linalg.norm(x_normal, axis=1)[:, np.newaxis] | |
idx_pairs = itertools.product(range(N), range(N)) | |
best = min([np.linalg.norm(x_spherical[i] - x_spherical[j]) for i, j in idx_pairs if i != j]) | |
print('Distance of closest pair among {} points (dim = {}): {}'.format(N, d, best)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment