Class: TeaLeaves::SeasonalComponents
- Inherits:
-
Object
- Object
- TeaLeaves::SeasonalComponents
- Defined in:
- lib/tealeaves/seasonal_components.rb
Instance Method Summary collapse
-
#initialize(period, data) ⇒ SeasonalComponents
constructor
A new instance of SeasonalComponents.
- #seasonal_averages ⇒ Object
- #seasonal_factors(operation = :-) ⇒ Object
Constructor Details
#initialize(period, data) ⇒ SeasonalComponents
Returns a new instance of SeasonalComponents.
3 4 5 6 |
# File 'lib/tealeaves/seasonal_components.rb', line 3 def initialize(period, data) @period = period @data = data end |
Instance Method Details
#seasonal_averages ⇒ Object
8 9 10 11 12 |
# File 'lib/tealeaves/seasonal_components.rb', line 8 def seasonal_averages @seasonal_averages ||= seasonal_groups.map do |group| group.inject(&:+) / group.size.to_f end end |
#seasonal_factors(operation = :-) ⇒ Object
14 15 16 |
# File 'lib/tealeaves/seasonal_components.rb', line 14 def seasonal_factors(operation = :-) @seasonal_factors ||= seasonal_averages.map {|i| i.send(operation, avg) } end |