函数 mean #

计算矩阵或数值列表的平均值。对于多维数组,将计算展平数组的平均值。如果提供了 dim 参数,则将计算选定维度的最大值。参数 dim 是零基索引的。

Syntax #

math.mean(a, b, c, ...)
math.mean(A)
math.mean(A, dimension)

Parameters #

Parameter Type Description
args … * 单个矩阵或多个标量值

Returns #

Type Description
* 所有值的平均值

Throws #

Type | Description —- | ———–

Examples #

math.mean(2, 1, 4, 3)                     // returns 2.5
math.mean([1, 2.7, 3.2, 4])               // returns 2.725

math.mean([[2, 5], [6, 3], [1, 7]], 0)    // returns [3, 5]
math.mean([[2, 5], [6, 3], [1, 7]], 1)    // returns [3.5, 4.5, 4]

另请参阅 #

median, min, max, sum, prod, std, variance

Fork me on GitHub