def cum_percentile(series,q):
    """ Takes a series of ordered frequencies and returns the value at a specified quantile
    Parameters:
    series - Series
        The series to analyze
    q - number
        Quantile to get the value of
    """
    total = series.sum()
    cum_sum = series.cumsum()
    return sum(cum_sum < total*q)