Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

np.random.choice replace

#You can use it when you want sample some elements from a list, 
#and meanwhile you want the elements no repeat,
#then you can set the "replace=False".

eg:
from numpy import random as rd
ary = list(range(10))
rd.choice(ary, size=8, replace=False)
[out] : array([0, 5, 9, 8, 2, 1, 6, 3])  # no repeated elements
rd.choice(ary, size=8, replace=True)
[Out]: array([4, 9, 8, 5, 4, 1, 1, 9])  # elements may be repeated
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #replace
ADD COMMENT
Topic
Name
7+6 =