average(a, axis=None, weights=None, returned=False)
This docstring was copied from numpy.ma.average.
Some inconsistencies with the Dask version may exist.
Data to be averaged. Masked entries are not taken into account in the computation.
Axis along which to average a
. If None, averaging is done over the flattened array.
The importance that each element has in the computation of the average. The weights array can either be 1-D (in which case its length must be the size of a
along the given axis) or of the same shape as a
. If weights=None
, then all data in a
are assumed to have a weight equal to one. The 1-D calculation is:
avg = sum(a * weights) / sum(weights)
The only constraint on :None:None:`weights`
is that :None:None:`sum(weights)`
must not be 0.
Flag indicating whether a tuple (result, sum of weights)
should be returned as output (True), or just the result (False). Default is False.
The average along the specified axis. When returned is :None:None:`True`
, return a tuple with the average as the first element and the sum of the weights as the second element. The return type is :None:None:`np.float64`
if a
is of integer type and floats smaller than :None:None:`float64`
, or the input data-type, otherwise. If returned, :None:None:`sum_of_weights`
is always :None:None:`float64`
.
Return the weighted average of array over the given axis.
>>> a = np.ma.array([1., 2., 3., 4.], mask=[False, False, True, True]) # doctest: +SKIPThis example is valid syntax, but we were not able to check execution
... np.ma.average(a, weights=[3, 1, 0, 0]) # doctest: +SKIP 1.25
>>> x = np.ma.arange(6.).reshape(3, 2) # doctest: +SKIPThis example is valid syntax, but we were not able to check execution
... x # doctest: +SKIP masked_array( data=[[0., 1.], [2., 3.], [4., 5.]], mask=False, fill_value=1e+20)
>>> avg, sumweights = np.ma.average(x, axis=0, weights=[1, 2, 3], # doctest: +SKIPSee :
... returned=True)
... avg # doctest: +SKIP masked_array(data=[2.6666666666666665, 3.6666666666666665], mask=[False, False], fill_value=1e+20)
The following pages refer to to this document either explicitly or contain code examples using this.
dask.array.routines.average
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them