def quantile(percent, data):
    """
    Compute the quantile such that 100p% of data lies above the output
    value.
    """
    if not data:
        return data
    data.sort()
    index = int(percent*len(data) + 0.5) - 1
    if index < 0:
        index = 0
    return data[index]