Module: ArrayFastMethods
- Included in:
- Array
- Defined in:
- lib/array_fast_methods.rb,
lib/array_fast_methods/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
Instance Method Details
#mean ⇒ Object
5 6 7 |
# File 'lib/array_fast_methods.rb', line 5 def mean (sum.to_f / size.to_f) end |
#std_dev ⇒ Object
16 17 18 |
# File 'lib/array_fast_methods.rb', line 16 def std_dev Math.sqrt(variance) end |
#variance ⇒ Object
9 10 11 12 13 14 |
# File 'lib/array_fast_methods.rb', line 9 def variance m = mean sum_let = 0.0 each {|v| sum_let += (v-m)**2 } sum_let/size end |