Let's assume that we got a list like the one below:
list = [[A,10,3],[B,5,2],[C,8,1]]
For each item in the list there is a probability to be chosen which could be calculated by softmax. for example for first element (A) we have:
from math import exp
A_probability = exp(list[0][2]/list[0][1] / (exp(list[0][2]/list[0][1]) + exp(list[1][2]/list[1][1]) + exp(list[2][2]/list[2][1]))
How can I choose the items in the list randomly according to the calculated probablity for each one?
Aucun commentaire:
Enregistrer un commentaire