average

average(array<number> array) → real averageValue
Computes the average of values in array array.

Computes the average of the elements contained in the array array.

The average is computed by converting each element to a real number, adding them up, and finally dividing this sum by the size of the array.

Parameters
Return
Examples
var array = [10, 15.5, 16, 18, 13]
debug("average = " + average(array)) // Displays 14.5
const array = [10, 15.5, 16, 18, 13]
const avg = array.reduce((s, x) => s + x, 0) / array.length
Debug.log("average = " + avg) // Displays 14.5
import statistics
array = [10, 15.5, 16, 18, 13]
Debug.log(f"average = {statistics.mean(array)}")  # Displays 14.5