idx = np.random.choice(perm.shape[0], nsamp, replace=False)
How to generate random pairs of numbers in Python, including pairs with one entry being the same and excluding pairs with both entries being the same?