Summarize a posterior by a credible region holding a given probability mass (for example 0.95), in the two ways of Murphy's book.
central_interval(samples, mass): the equal-tailed interval, the empirical quantiles at and computed with numpy.quantile (default linear interpolation). Return (lo, hi).hdi_from_samples(samples, mass): the shortest interval containing of the sorted samples. Among all windows of consecutive sorted samples, return the endpoints (lo, hi) of the narrowest one (the first such window on ties).hdi_from_grid(grid, density, mass): density holds unnormalized posterior density values at the increasing points of grid. Treat each point as carrying mass proportional to its density, normalized to sum to one. Keep the smallest set of points with the highest densities whose total mass reaches mass (add points in decreasing order of density until the running total is at least mass). Return the kept region as a list of (start, end) grid-value tuples, one per maximal run of consecutive kept points, in increasing order. A multimodal density can give several segments.Return floats.