Jul-17-2017, 05:39 PM
Dear Python Users,
Please, help me with the following issue. I have two lists: train_X and train_Y. What I want to do is to create a new list that will contain forecasts (F) from the following formula: F_(t+1) = alpha*train_Y + (1-alpha)* F_t. Note: the first entry in Forecast(F) should equal to first entry in train_Y. Look at this example:
Alpha = 0.5
Train_Y Forecast
10 10
20 10 = 10*0.5 + 10*(1-0.5)
30 15 = 20*0.5 + (1-0.5)*10
40 22.5 = 30*0.5 +(1-0.5)*15
So far I have the following code (but it does not work and I am stuck): train_X is indexing of entries in train_y
Please, help me with the following issue. I have two lists: train_X and train_Y. What I want to do is to create a new list that will contain forecasts (F) from the following formula: F_(t+1) = alpha*train_Y + (1-alpha)* F_t. Note: the first entry in Forecast(F) should equal to first entry in train_Y. Look at this example:
Alpha = 0.5
Train_Y Forecast
10 10
20 10 = 10*0.5 + 10*(1-0.5)
30 15 = 20*0.5 + (1-0.5)*10
40 22.5 = 30*0.5 +(1-0.5)*15
So far I have the following code (but it does not work and I am stuck): train_X is indexing of entries in train_y
train_X = [1,2,3,4,5] train_Y = [10, 20, 30, 40, 50] alpha = int(input("Input alpha: ")) forecast = [] for x in range(0, len(train_X)+1): if x==0: forecast.append(train_Y[0]) else: forecast.append(alpha*train_Y + (1 - alpha) * forecast[x-1])