lib/ddmetrics/stats.rb in ddmetrics-1.0.1 vs lib/ddmetrics/stats.rb in ddmetrics-1.1.0
- old
+ new
@@ -20,10 +20,11 @@
@values.size
end
def sum
raise EmptyError if @values.empty?
+
@values.reduce(:+)
end
def avg
sum.to_f / count
@@ -40,10 +41,10 @@
def quantile(fraction)
raise EmptyError if @values.empty?
target = (@values.size - 1) * fraction.to_f
interp = target % 1.0
- sorted_values[target.floor] * (1.0 - interp) + sorted_values[target.ceil] * interp
+ (sorted_values[target.floor] * (1.0 - interp)) + (sorted_values[target.ceil] * interp)
end
private
def sorted_values