Project

General

Profile

Actions

Feature #18057

open

Introduce Array#mean

Added by ggmichaelgo (Michael Go) 3 months ago. Updated 3 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:104740]

Description

Introduce Array#average to calculate the average value of an array.

array = [1, 2, 3]
array.mean # 2

array = [1.5, 2.2, 3.1]
array.mean(&:round) # 2.3333333333333335

array = [-3, -2, -1]
array.mean { |e| e.abs } # 2
Actions

Also available in: Atom PDF