class ExoBasic::DecayingAvg
Constants
- DEFAULT_D
Attributes
avg[R]
d[R]
meta[R]
Public Class Methods
new(d=DEFAULT_D)
click to toggle source
# File lib/exobasic/stats/decaying_avg.rb, line 9 def initialize(d=DEFAULT_D) @d = d <= 0 ? DEFAULT_D : d @avg = 0.0 @meta = AvgMeta.new end
Public Instance Methods
==(other)
click to toggle source
# File lib/exobasic/stats/decaying_avg.rb, line 26 def ==(other) @d == other.d && StatsHelpers.double_equals(@avg, other.avg) && @meta == other.meta end
d=(d)
click to toggle source
# File lib/exobasic/stats/decaying_avg.rb, line 15 def d=(d) @d = d <= 0 ? DecayingAvg::DEFAULT_D : d end
offer(x)
click to toggle source
# File lib/exobasic/stats/decaying_avg.rb, line 19 def offer(x) @meta = @meta.offer(x, @avg, d) d_prime = @d.to_f @avg = x / d_prime + (d_prime - 1.0) * @avg / d_prime end