Mean

Mean( arrayOrSet )
Mean( arrayOrSet )
Mean( arrayOrSet )
Mean( arrayOrSet )
mean( arrayOrSet )
Not available in this language yet.
Mean( arrayOrSet )
Not available in this language yet.

Description

The Mean function returns the average value of the items in arrayOrSet, which is an Array, Page, or Set. The mean is calculated by dividing the sum of the arrayOrSet's values by the count of the arrayOrSet's values.

Parameters

Argument Type Definition and Requirements

arrayOrSet

Array, Page, or Set

The array, page, or set that should have its average value calculated.

Returns

A Number representing the average value of all items in arrayOrSet.

Examples

The following query returns the average of the items in the provided array:

Value result = await client.Query(
  Mean(Arr(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
);

IResult<Value> data = result.To<Value>();
data.Match(
  Success: value => Console.WriteLine($"{value}"),
  Failure: error => Console.WriteLine($"Query failed:\n{error}")
);
result, err := client.Query(
  f.Mean(f.Arr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}))

if (err != nil) {
  fmt.Println(err)
} else {
  fmt.Println(result)
}
System.out.println(
    client.query(
        Mean(
            Arr(
                Value(1), Value(2), Value(3), Value(4), Value(5),
                Value(6), Value(7), Value(8), Value(9), Value(10)
            )
        )
    ).get()
);
client.query(
  q.Mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
)
.then((ret) => console.log(ret))
print(client.query(
  q.mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
))
println(Await.result(
  client.query(
    Mean(Arr(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
  ),
  5.seconds)
)
Not available in this language yet.
Not available in this language yet.
DoubleV(5.5)
5.5
5.5
5.5
5.5
5.5

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!