Sha256: fc9175e4d37e9b4ff68f3ba1c9d4c0317f231b637f86c97db7878fdb751c5358
Contents?: true
Size: 401 Bytes
Versions: 1
Compression:
Stored size: 401 Bytes
Contents
require 'bigdecimal' require 'bigdecimal/util' module FeCoreExt::CoreExt end module FeCoreExt::CoreExt::Array def median return if empty? sorted = sort len = sorted.length (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0 end def sum inject(0) { |result, el| result + el } end def mean sum.to_d / size end end class Array include FeCoreExt::CoreExt::Array end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fe_core_ext-0.1.12 | lib/fe_core_ext/core_ext/array.rb |