Module: FeCoreExt::CoreExt::Array

Included in:
Array
Defined in:
lib/fe_core_ext/core_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#meanObject



15
16
17
18
# File 'lib/fe_core_ext/core_ext/array.rb', line 15

def mean
  return if empty?
  sum.to_d / size
end

#medianObject



8
9
10
11
12
13
# File 'lib/fe_core_ext/core_ext/array.rb', line 8

def median
  return if empty?
  sorted = sort
  len = sorted.length
  (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
end