Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-107

Theta Method Forecast

Problem

Compute the theta method forecast h steps ahead: the SES forecast with smoothing factor alpha plus 0.5 * h * slope, where slope is the OLS slope of the series on time.

Return 0.0 for an empty series; a single point has slope 0.

Hint

The theta method blends exponential smoothing with half the linear trend.

Test cases

case 1
in: [[1,2,3,4],0.5,1]
expected: 3.625
case 2
in: [[1,2,3,4],0.5,2]
expected: 4.125
case 3
in: [[5,5,5],0.3,1]
expected: 5
case 4
in: [[10],0.7,3]
expected: 10
Starter codePython
def theta_method_forecast(series, alpha, h):
    # Your code here
    pass

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