According to the http://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.random.choice.html, using the replace = False with Numpy's random.choice method should make the sample without replacement. However, this does not seem to work for me:
In [33]: import numpy as np
In [34]: arr = range(5)
In [35]: number = np.random.choice(arr, replace = False)
In [36]: arr
Out[36]: [0, 1, 2, 3, 4]
The array arr is still range(5) after sampling, and not missing a (random) number as I would expect. How could I sample a number from range(5) without replacement?
np.random.choicedoes not mutate the original array. It's not literally sampling from the array. - juanpa.arrivillagaarr. - Divakarnp.random.choice(arr, 2, replace=False)- ayhanarray arr is still range(5), hence my earlier comment. - Divakar