Sha256: 8c997ecc4e3a35a5d2f55aab4b5b10949b8005af9213b782fe37eefd9813ab6f
Contents?: true
Size: 440 Bytes
Versions: 3
Compression:
Stored size: 440 Bytes
Contents
class Array def mean self.sum.to_f / self.length end def arithmetric_mean self.mean end def geometric_mean self.product.to_f ** (1.0 / self.length) end def harmonic_mean self.length / self.map{ |x| 1.0 / x }.sum.to_f end def quadratic_mean self.power_mean(2) end def power_mean(p = 1) ((1.0 / self.length) * self.map{ |x| x ** p }.sum.to_f) ** (1.0 / p) end end
Version data entries
3 entries across 3 versions & 1 rubygems