All problems
Direct and Recursive Blend
Problem
Combine a recursive multi-step forecast and a direct forecast: weight * direct_value + (1 - weight) * recursive_value.
Return the blended value. weight = 1 uses only the direct forecast.
Hint
Blending hedges the bias of recursive extrapolation against direct-model variance.
Test cases
case 1
in: [10,12,0.5]
expected: 11
case 2
in: [10,12,1]
expected: 12
case 3
in: [10,12,0]
expected: 10
case 4
in: [3,5,0.25]
expected: 3.5
Starter codePython
def direct_recursive_blend(recursive_value, direct_value, weight):
# Your code here
pass4 test cases · run your code against them in the editor