python - Re-scale the probabilities to make the sum of the probabilities to 1 -
this question has answer here:
- normalize small probabilities in python 2 answers
i have list of probabilities follows
probability_list = [0.9, 0.8, 0.0, 0.2, 1.0]
each value represents probability of appearing given word.
e.g., 0.9 -> denotes probability of appearing word_1 0.9 e.g., 0.8 -> denotes probability of appearing word_2 0.8 , on.
now want re-scale aforementioned probability_list
way sum
of becomes 1
.
please suggest me suitable approach this.
the easiest way sum of list , divide each element list comphrension:
total = sum(probability_list) probability_list = [i/total in probability_list]
Comments
Post a Comment