Class: TeaLeaves::ExponentialSmoothingForecast::SeasonalityStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/tealeaves/exponential_smoothing_forecast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(period, gamma) ⇒ SeasonalityStrategy

Returns a new instance of SeasonalityStrategy.



8
9
10
11
# File 'lib/tealeaves/exponential_smoothing_forecast.rb', line 8

def initialize(period, gamma)
  @gamma = gamma
  @start_index = period
end

Instance Attribute Details

#start_indexObject (readonly)

Returns the value of attribute start_index.



6
7
8
# File 'lib/tealeaves/exponential_smoothing_forecast.rb', line 6

def start_index
  @start_index
end

Instance Method Details

#new_values(observed_value, parameters, new_level) ⇒ Object



13
14
15
16
17
# File 'lib/tealeaves/exponential_smoothing_forecast.rb', line 13

def new_values(observed_value, parameters, new_level)
  new_seasonality = @gamma * t(observed_value, new_level) + 
    (1 - @gamma) * parameters[:seasonality].first
  parameters[:seasonality].drop(1) << new_seasonality
end