All problems
Credible Interval Width
Problem
Compute the width of a symmetric credible interval from a posterior variance: 2 * z * sqrt(post_var), where z is the normal critical value.
Return 0.0 when post_var is not positive.
Hint
The width scales with the square root of the posterior variance.
Test cases
case 1
in: [4,1.96]
expected: 7.84
case 2
in: [1,1.645]
expected: 3.29
case 3
in: [0,2]
expected: 0
case 4
in: [2.25,2]
expected: 6
Starter codePython
def credible_interval_width(post_var, z):
# Your code here
pass4 test cases · run your code against them in the editor