Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by codereview.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #map #data #scale #python
ADD COMMENT
Topic
Name
5+4 =