In Python, I have a list of integers from 0 to K-1: [0, 1, ..., K-1] I also have a list of corresponding probabilities: [p_0, ..., p_{k-1}]
The lists have equal lengths.
I want to randomly choose one of those K numbers, where the probability of choosing any of the numbers is given by the corresponding probability in the second list.
I will need to do this many times. What is the fastest way to do this in Python?
Aucun commentaire:
Enregistrer un commentaire