Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/immosquare-extensions/array.rb
Overview
##
This extension adds utility methods to the Array class.
##
Instance Method Summary collapse
-
#mean ⇒ Object
## Calculate the average (mean) of an array of numbers.
Instance Method Details
#mean ⇒ Object
##
Calculate the average (mean) of an array of numbers. The mean is the sum of the numbers divided by the count.
Reference: www.chrisjmendez.com/2018/10/14/mean-median-mode-standard-deviation/
Examples: [1, 2, 3, 4, 5].mean => 3.0 [2, 4, 6].mean => 4.0
##
17 18 19 |
# File 'lib/immosquare-extensions/array.rb', line 17 def mean sum(0.0) / size end |