In an attempt to implement the log_prob() method for an Empirical distribution function, I need to match the entries of a big tensor with samples. My naive implementation is terribly slow:
samples = torch.randn(10)
value = torch.randn(10000)

num_matches = torch.zeros_like(values)
for i, v in enumerate(value):
    num_matches[i] = torch.isclose(samples, v).sum()

Does somebody have a suggestion, how I could speed it up?