Project

General

Profile

Actions

Feature #18057

open

Introduce Array#mean

Added by ggmichaelgo (Michael Go) about 4 years ago. Updated over 1 year ago.

Status:
Open
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

Related issues 1 (1 open0 closed)

Related to Ruby - Feature #21518: Statistical helpers to `Enumerable`OpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0