Answers for "how to map data to a scale python"

0

how to map data to a scale python

def scale(x, out_range=(-1, 1)):
    domain = np.min(x), np.max(x)
    y = (x - (domain[1] + domain[0]) / 2) / (domain[1] - domain[0])
    return y * (out_range[1] - out_range[0]) + (out_range[1] + out_range[0]) / 2
Posted by: Guest on May-19-2021

Browse Popular Code Answers by Language