lundi 17 juin 2019

Is there any way to pick weighted random values along with random number of pick value?

I have below kind of data with me

keys = [a] , [b] , [a,c] , [b,c,a]

frequencies = [1] , [2] , [2,2] , [1,1,2]

count = 1, 1, 2, 3

def get_item(items, items_weights):
    return random.choices(items, weights=items_weights)

above function just provides me single random key from my data I want multiple keys based on distribution of count

I want to pick keys based on their frequencies as well as count so that I can get random keys with random count




Aucun commentaire:

Enregistrer un commentaire