Could you help me compute N random pairs vectors x and y with size d and such that x_i and y_i belong to the real range U[-1,1] and such that the euclidean distance between x and y could be less or equal than a small T? I need to compute these N pairs efficiently (in terms of time) in Python.
I tried
import numpy as np
d = 4
inv_d = 1.0 / d
random_lst = []
T = 0.05
N = 10
for i in range(N):
while(1):
x = np.random.uniform(low=-1, high=1, size=d)
y = np.random.uniform(low=-1, high=1, size=d)
length = np.linalg.norm(x-y)
if length <= T:
random_lst.append([x,y])
print(length)
break
print(random_lst)
But it took a lot of time (40s), and I need N near from 10^6, that is maybe it could be take even more time