Answers for "np random choice given distribution"

0

random choice sampling numpy

>>> np.random.choice(5, 3, replace=False)
array([3,1,0])
>>> #This is equivalent to np.random.permutation(np.arange(5))[:3]
Posted by: Guest on June-15-2020
0

np random choice given distribution

np.random.choice(5, 3, p=[0.1, 0, 0.3, 0.6, 0])
array([3, 3, 0]) # random
Posted by: Guest on March-14-2022
0

np random choice given distribution

aa_milne_arr = ['pooh', 'rabbit', 'piglet', 'Christopher']
>>> np.random.choice(aa_milne_arr, 5, p=[0.5, 0.1, 0.1, 0.3])
array(['pooh', 'pooh', 'pooh', 'Christopher', 'piglet'], # random
      dtype='<U11')
Posted by: Guest on January-17-2022

Python Answers by Framework

Browse Popular Code Answers by Language