Commit 0f7c8d2e authored by Ben Farr's avatar Ben Farr
Browse files

Add utility for calculating credible bounds of function

parent 263b8bd1
......@@ -91,3 +91,15 @@ def extract_map_sample(infile, params=None):
samples = extract_samples(infile, params)
return samples[map_idx]
def credible_bounds(function_samples, cl=0.95):
"""
Get the upper and lower credible boundaries of a 1-D function from a sample.
"""
function_samples = np.atleast_2d(function_samples)
N = function_samples.shape[0]
sorted_samples = np.sort(function_samples, axis=0)
low = sorted_samples[int((1-cl)/2.*N), :]
high = sorted_samples[int((1+cl)/2.*N), :]
return low, high
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment