Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/immosquare-extensions/array.rb

Overview

##

This extension adds utility methods to the Array class.

##

Instance Method Summary collapse

Instance Method Details

#meanObject

##

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