Normalizing a list of numbers in Python

前端 未结 9 1212
北荒
北荒 2020-12-05 06:37

I need to normalize a list of values to fit in a probability distribution, i.e. between 0.0 and 1.0.

I understand how to normalize, but was curious if Pytho

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 07:14

    if your list has negative numbers, this is how you would normalize it

    a = range(-30,31,5)
    norm = [(float(i)-min(a))/(max(a)-min(a)) for i in a]
    

提交回复
热议问题