normalize_values

compas.itertools.normalize_values(values, new_min=0.0, new_max=1.0)[source]

Normalize a list of numbers to the range between new_min and new_max.

Parameters:
valuessequence[float]

The data to be normalized.

new_minfloat, optional

The new minimum of the data.

new_maxfloat, optional

The new maximum of the data.

Returns:
list[float]

A new list of floats mapped to the range new_min, new_max.

Examples

>>> data = list(range(5, 15))
>>> data = normalize_values(data)
>>> min(data)
0.0
>>> max(data)
1.0