AVG function

AVG function

Function Name Description Usage Input parameter Return value
AVG Calculates the numerical average of all the values in an array. AVG() N/A Average of all the values in an array. The return value is of type Double.

Supported data type

The AVG function supports the following data types:

  • Double array
  • Integer array

Example 1: Calculate the average of all the values in an integer array

Sample data: $var1$ = {2,4,9,3}

Usage: $var1$.AVG()

Calculate the average of values in var1.

Output: 4.5

Example 2: Calculate the average of all the values in a double array

Sample data: $var1$ = {2.0,6.1,3.9}

Usage: $var1$.AVG()

Calculate the average of values in var1.

Output: 4.0

Recommendation

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年12月09日 UTC.