lib/axiom/aggregate/mean.rb in axiom-0.1.1 vs lib/axiom/aggregate/mean.rb in axiom-0.2.0
- old
+ new
@@ -15,18 +15,18 @@
#
# @param [Array(Integer, Numeric)] accumulator
#
# @param [Numeric] value
#
- # @return [Array(Integer, Numeric)]
+ # @return [Array(Integer, Rational)]
#
# @api public
def self.call(accumulator, value)
return accumulator if value.nil?
count, mean = accumulator
count = Count.call(count, value)
- [count, mean ? Rational(value - mean, count) + mean : Rational(value)]
+ [count, mean ? Rational(value - mean, count) + mean : value.to_r]
end
# Extract the mean from the accumulator
#
# @example
@@ -39,10 +39,11 @@
# @return [nil]
# returned for an empty set
#
# @api public
def self.finalize(accumulator)
- accumulator.last
+ mean = accumulator.last
+ mean.to_f if mean
end
# Return the type returned from #call
#
# @example