This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def credible_interval(xlim, ys, mass=0.95): | |
"""Given a range, like (0, 20), and the y values for the probability density function, | |
returns the set of intervals spanning the minimum range to sum up to the mass.""" | |
indexed = zip(ys, range(len(ys))) | |
indexed.sort(reverse=True) | |
acc = 0 | |
points = [] | |
for (y, x) in indexed: |