normalize_values

compas.utilities.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
  • values (sequence[float]) – The data to be normalized.

  • new_min (float, optional) – The new minimum of the data.

  • new_max (float, 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