原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.average.html
校对:(虚位以待)
numpy.ma.
average
(a, axis=None, weights=None, returned=False)[source]返回给定轴上数组的加权平均值。
参数: | a:array_like
axis:int,可选
权重:array_like,可选
返回:bool,可选
|
---|---|
返回: | average,[sum_of_weights]:(tuple of)scalar或MaskedArray
|
例子
>>> a = np.ma.array([1., 2., 3., 4.], mask=[False, False, True, True])
>>> np.ma.average(a, weights=[3, 1, 0, 0])
1.25
>>> x = np.ma.arange(6.).reshape(3, 2)
>>> print(x)
[[ 0. 1.]
[ 2. 3.]
[ 4. 5.]]
>>> avg, sumweights = np.ma.average(x, axis=0, weights=[1, 2, 3],
... returned=True)
>>> print(avg)
[2.66666666667 3.66666666667]