def get_belief_at_cumulative_probability(df: 'classes.BeliefsDataFrame',
    cumulative_probability: float) ->'classes.BeliefsDataFrame':
    """Take the first value with cumulative probability equal or higher than the probability given.
    This selects the right value assuming a discrete probability distribution."""
    if not len(df) > 1:
        return df
    df2 = df[df.index.get_level_values('cumulative_probability') >=
        cumulative_probability]
    if df2.empty:
        return df.tail(1)
    else:
        return df2.head(1)
