Normalizing a list of numbers in Python

Adam_G

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 Python had a function to automate this.

I'd like to go from:

raw = [0.07, 0.14, 0.07]  

to

normed = [0.25, 0.50, 0.25]
Tony Suffolk 66

Use :

norm = [float(i)/sum(raw) for i in raw]

to normalize against the sum to ensure that the sum is always 1.0 (or as close to as possible).

use

norm = [float(i)/max(raw) for i in raw]

to normalize against the maximum

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

When normalizing list of numbers, result is all zeros

From Dev

Python: how to avoid a loop for normalizing a list of list?

From Dev

Normalizing a list of restaurant dishes

From Dev

Normalizing an adjacency list

From Dev

Reading numbers from file and normalizing

From Dev

Matplotlib (Python) normalizing data

From Dev

MySQL Workbench - Normalizing a List of Data

From Dev

Normalizing Numbers to a 0-100% Range

From Dev

normalizing JSON datestrings to UTC python

From Java

lambda if with list of numbers in python

From Dev

Python replacing numbers in a list

From Dev

Python add numbers in a list

From Dev

Parse list of numbers into list in python

From Dev

Normalizing inline-block list item height

From Dev

Python: Minimum Numbers in List, Including Repeated Numbers

From Dev

Python: normalizing some of the columns of a pandas DataFrame

From Dev

Having Trouble Normalizing Posterior Distribution in Python

From Dev

Dynamic Time Wrap (DTW) normalizing, python implementation

From Dev

Permutations of a list of input numbers in Python

From Dev

Python CSV multiple numbers in the list

From Dev

python convert bytearray to numbers in list

From Dev

creating list of random numbers in python

From Dev

Return positive numbers of a list in python

From Dev

asking for numbers in python and returning a list

From Dev

Comparing a sequence of numbers in a python list

From Dev

creating list of random numbers in python

From Dev

Permutations of a list of input numbers in Python

From Dev

Printing list in Python with serial numbers

From Dev

filtering numbers from Python list