I would like to distribute an integer for example 20, into four parts following the probability for each part:p=[0.02,0.5,0.3,0.18]
The corresponding python code is:
frequency=np.random.choice([1,2,3,4],20,p=[0.02,0.5,0.3,0.18])
from collections import Counter
Counter(frequency)
# Out[86]:
# Counter({1: 1, 2: 9, 3: 8, 4: 2})
However, I have over 1e6~ many parts that I would like to use tensorflow gpu to conquer this issue. Does anyone know how to do this?
Aucun commentaire:
Enregistrer un commentaire