def target_glucose_value(percent_effect_duration, min_value, max_value):
    """ Computes a target glucose value for a correction, at a given time
        during the insulin effect duration

    Arguments:
    percent_effect_duration -- percent of time elapsed of the insulin
                               effect duration
    min_value -- minimum (starting) target value
    max_value -- maximum (starting) target value

    Output:
    A target value somewhere between the minimum and maximum (inclusive)
    """
    use_min_value_until_percent = 0.5
    if percent_effect_duration <= use_min_value_until_percent:
        return min_value
    if percent_effect_duration >= 1:
        return max_value
    slope = (max_value - min_value) / (1 - use_min_value_until_percent)
    return min_value + slope * (percent_effect_duration -
        use_min_value_until_percent)
