lib/darkext/statistics.rb in darkhelmet-darkext-0.5.1 vs lib/darkext/statistics.rb in darkhelmet-darkext-0.5.2

- old
+ new

@@ -10,9 +10,19 @@ self.sum / self.size.to_f end alias :average :mean alias :ave :mean + def harmonic_mean + self.size.to_f / self.map { |i| 1 / i.to_f }.sum + end + alias :h_mean :harmonic_mean + + def geometric_mean + self.product.root(self.size) + end + alias :g_mean :geometric_mean + # Finds the median of the array def median return nil if self.size.zero? case self.size % 2 when 0