Sha256: c336da8e4b1ee527b7291207291ffd716b1c39777b79757e1c2059240c034a57

Contents?: true

Size: 362 Bytes

Versions: 40

Compression:

Stored size: 362 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 mean
    return if empty?
    sum.to_d / size
  end
end

class Array
  include FeCoreExt::CoreExt::Array
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
fe_core_ext-0.6.0 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.5.0 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.4.0 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.3.0 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.2.2 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.2.1 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.49 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.48 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.47 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.46 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.45 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.44 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.43 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.42 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.41 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.40 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.39 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.38 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.37 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.36 lib/fe_core_ext/core_ext/array.rb