Class: Ema
- Inherits:
-
Object
- Object
- Ema
- Defined in:
- lib/rbma/ema.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#a ⇒ Object
readonly
S_t = alpha*Y_t+(1-alpha)*S_(t-1).
-
#last ⇒ Object
readonly
Returns the value of attribute last.
Instance Method Summary collapse
- #compute(current:, previous: nil) ⇒ Object
-
#initialize(a:) ⇒ Ema
constructor
A new instance of Ema.
- #to_s ⇒ Object
Constructor Details
#initialize(a:) ⇒ Ema
Returns a new instance of Ema.
7 8 9 |
# File 'lib/rbma/ema.rb', line 7 def initialize(a:) @a = a end |
Instance Attribute Details
#a ⇒ Object (readonly)
S_t = alpha*Y_t+(1-alpha)*S_(t-1)
3 4 5 |
# File 'lib/rbma/ema.rb', line 3 def a @a end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
5 6 7 |
# File 'lib/rbma/ema.rb', line 5 def last @last end |
Instance Method Details
#compute(current:, previous: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/rbma/ema.rb', line 11 def compute(current:, previous: nil) if previous @last = @a*current+(1-@a)*previous elsif @last @last = @a*current+(1-@a)*@last else @last = current end end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/rbma/ema.rb', line 21 def to_s "#{@last}" end |