Class: TeaLeaves::ExponentialSmoothingForecast::SeasonalityStrategy
- Inherits:
-
Object
- Object
- TeaLeaves::ExponentialSmoothingForecast::SeasonalityStrategy
- Defined in:
- lib/tealeaves/exponential_smoothing_forecast.rb
Direct Known Subclasses
AdditiveSeasonalityStrategy, MultiplicativeSeasonalityStrategy, NoSeasonalityStrategy
Instance Attribute Summary collapse
-
#start_index ⇒ Object
readonly
Returns the value of attribute start_index.
Instance Method Summary collapse
-
#initialize(period, gamma) ⇒ SeasonalityStrategy
constructor
A new instance of SeasonalityStrategy.
- #new_values(observed_value, parameters, new_level) ⇒ Object
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_index ⇒ Object (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 |