lib/darkext/statistics.rb in darkhelmet-darkext-0.5.2 vs lib/darkext/statistics.rb in darkhelmet-darkext-0.5.3
- old
+ new
@@ -64,9 +64,15 @@
def sample_deviation
self.sample_variance.abs.sqrt
end
+ def geometric_deviation
+ gmean = self.g_mean
+ Math.exp((self.map { |x| (x.ln - gmean.ln).square }.sum.to_f / self.size.to_f).sqrt)
+ end
+ alias :gstddev :geometric_deviation
+
# Randomly samples n elements
def sample(n = 1)
(1..n).collect { self[rand(self.size)] }
end