I have got a list of 2d coordinates with this structure:
coo = [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0)]
Where coo[0]
is the first coordinate stored in a tuple.
I would like to choose two random coordinates. I can of course use this method:
import numpy as np
rndcoo1 = coo[np.random.randint(0,len(coo))]
rndcoo2 = coo[np.random.randint(0,len(coo))]
But because I have to repeat this operation 1'000'000 times I was wondering if there is a faster method to do that. np.random.choice()
can't be used for 2d array is there any alternative that I can use?
Aucun commentaire:
Enregistrer un commentaire