All problems
Random Walk Forecast Interval Width
Problem
Compute the width of a symmetric forecast interval for a random walk: 2 * z * sigma * sqrt(h).
Return 0.0 for h <= 0. Here z is the normal critical value, e.g. 1.96 for 95 percent coverage.
Hint
The interval fans out as the square root of the forecast horizon.
Test cases
case 1
in: [1,4,1.96]
expected: 7.84
case 2
in: [0.5,9,1.645]
expected: 4.9350000000000005
case 3
in: [2,0,1.96]
expected: 0
case 4
in: [1,1,2]
expected: 4
Starter codePython
def random_walk_interval_width(sigma, h, z):
# Your code here
pass4 test cases · run your code against them in the editor