Return the weighted average of array over the given axis.
Parameters : | a : array_like
axis : int, optional
weights : array_like, optional
returned : bool, optional
|
---|---|
Returns : | average, [sum_of_weights] : (tuple of) scalar or MaskedArray
|
Examples
>>> 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]