Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

Math.mean()

Get the arithmetic mean of an Array or Set of Numbers.

Signatures

To average an Array of Numbers:

Math.mean(numbers: Array<Number>) => Number

To average a Set of Numbers:

Math.mean(numbers: Set<Number>) => Number

Description

Gets the arithmetic mean of an Array or Set of Numbers.

Parameters

Parameter Type Required Description

numbers

Array<Number> | Set<Number>

Yes

Numbers to average.

Return value

Type Description

Number

Arithmetic mean of the numbers.

Examples

Average an Array of numbers

Math.mean([1, 2, 3, 4, 4])
2.8

Average a Set of numbers

// Converts an array to a Set.
let set = [1, 2, 3, 4, 4.0].toSet()

Math.mean(set)
2.8

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!