def _interpolate(dist_in_interval, min_val, max_val, interval_length):
    """Linear interpolation between min_val and max_val.
    Interval assumed to be (0,interval_length)
    """
    if dist_in_interval > interval_length:
        raise ValueError
    if min_val > max_val:
        raise ValueError

    diff = max_val - min_val
    weight = dist_in_interval / interval_length

    return min_val + diff * weight