def get_parameter_summary_max_shortest(self, chain, parameter):
xs, ys, cs = self._get_smoothed_histogram(chain, parameter)
desired_area = chain.config["summary_area"]
c_to_x = interp1d(cs, xs, bounds_error=False, fill_value=(-np.inf, np.inf))
# Get max likelihood x
max_index = ys.argmax()
x = xs[max_index]
# Pair each lower bound with an upper to get the right area
x2 = c_to_x(cs + desired_area)
dists = x2 - xs
mask = (xs > x) | (x2 < x) # Ensure max point is inside the area
dists[mask] = np.inf
ind = dists.argmin()
return [xs[ind], x, x2[ind]]
评论列表
文章目录