Esempio n. 1
0
def _credible_interval(pmf, percentage):
    """
    Computes a credible interval for a given distribution.

    If percentage=90, computes the 90% CI.

    Args:
        pmf:        Pmf object representing a posterior distribution
        percentage: float between 0 and 100

    Returns:
        sequence of two floats, low and high
    """
    cdf = _13_Cdf._make_cdf_from_dict(pmf._get_dict())
    prob = (1 - percentage / 100.0) / 2
    interval = [cdf._value(p) for p in [prob, 1 - prob]]
    return interval