def map_range(x, out_min, out_max):
    """Linearly map the range of x from min(x), max(x) to out_min, out_max."""
    in_min, in_max = x.min(), x.max()
    return (x - in_min) / (in_max - in_min) * (out_max - out_min) + out_min