Skip to content
DeepForgeby svx
All problems
HardTime Seriests-264

Residual Bootstrap Mean

Problem

Build a bootstrap mean forecast: seed the random generator, sample residuals with replacement `paths` times, and return point_forecast + the mean of the sampled residuals.

Return point_forecast when residuals is empty or paths <= 0.

Hint

Seeding inside the function keeps bootstrap forecasts reproducible.

Test cases

case 1
in: [10,[-1,0,1],42,5]
expected: 10
case 2
in: [0,[2,4],7,4]
expected: 3
case 3
in: [5,[],1,3]
expected: 5
case 4
in: [3,[1],9,2]
expected: 4
Starter codePython
import random
def residual_bootstrap_mean(point_forecast, residuals, seed, paths):
    # Your code here
    pass

4 test cases · run your code against them in the editor