scale_to

scale_to(x, x_min=0, x_max=1)[source]

Linear scaling to new range of values.

This function scales the input values from their current range to the given range.

Parameters
x: array-like
x_min: float

Lower boarder of the new range

x_max: float

Upper boarder of the new range

Returns
out:

Scaled values

Examples

>>> y = np.array((-1,2,5,7))
>>> scale_to(y, x_min=0, x_max=1)
array([0.   , 0.375, 0.75 , 1.   ])