Module: ArrayFastMethods

Included in:
Array
Defined in:
lib/array_fast_methods.rb,
lib/array_fast_methods/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#meanObject



4
5
6
# File 'lib/array_fast_methods.rb', line 4

def mean
  (sum.to_f / size.to_f)
end

#std_devObject



15
16
17
# File 'lib/array_fast_methods.rb', line 15

def std_dev
  Math.sqrt(variance)
end

#varianceObject



8
9
10
11
12
13
# File 'lib/array_fast_methods.rb', line 8

def variance
  m = mean
  sum_let = 0.0
  each {|v| sum_let += (v-m)**2 }
  sum_let/size
end