samedi 30 avril 2022

Random choice out of 1D array with 2-dimensional probability in python

I would like to choose randomly out of a list with 3 elements (HGA, CGA, SGA), but I have 3 lists with the probabilities in it.

My probabilities are given by (the lists have the same length):

Probs = { 'HGA':prob['HGA'], 'CGA':prob['CGA'], 'SGA':prob['SGA'] }

and now I want to create another list which should look something like this without using a loop:

particles = ['HGA', 'CGA', 'CGA', 'CGA', 'SGA' ...]

The length of 'particles' should obviously have the same length as the probabilities.




Aucun commentaire:

Enregistrer un commentaire