def rescale(in_min, in_max, out_min, out_max, value):
    """Rescales value from the specified range to the specified other range.

    Arguments:
        in_min: min bound of the range of value.
        in_max: max bound of the range of value.
        out_min: min bound of the range of the output.
        out_max: max bound of the range of the output.
        value: a number to rescale from the input range to the output range.
    Return:
        (float) a number that is the same relative distance away from out_min and
        out_max as value was from in_min and in_max
    """
    return (value - in_min) * (out_max - out_min) / float(in_max - in_min) + out_min