vendredi 25 août 2017

Take repeated sample of a list

I have a list range(n) and want to take a random sample of r without replacing, i.e. np.random.choice(n,r, replace = False). But I want to do this often, is there a fast way for the following command:

a = [np.random.choice(n,r,replace = False) for i in range(100)]

Note: n and r can be "large", s.t. a = np.random.choice(n,(r,100), replace = True) and removing the ones that have two similar indexes will be inefficient.




Aucun commentaire:

Enregistrer un commentaire