mean
Calculates the arithmetic mean of the input array x
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
input array of a real-valued floating-point data type. |
required | |
axis
|
axis or axes along which arithmetic means must be computed.
By default, the mean is computed over the entire array.
If a tuple of integers, arithmetic means are computed over multiple axes. Default: |
None
|
|
keepdims
|
if |
False
|
Returns:
Name | Type | Description |
---|---|---|
out |
array
|
if the arithmetic mean was computed over the entire array, a zero-dimensional array with the arithmetic mean.
Otherwise, a non-zero-dimensional array containing the arithmetic means.
The returned array has the same data type as |
Special Cases
Let N
equal the number of elements over which to compute the arithmetic mean.
If N
is 0
, the arithmetic mean is NaN
.
If x_i
is NaN
, the arithmetic mean is NaN
(i.e., NaN
values propagate).
Examples:
>>> a = sparse.COO.from_numpy(np.array([[0, 1], [2, 0]]))
>>> o = sparse.mean(a, axis=1)
>>> o.todense()
array([0.5, 1. ])
Source code in sparse/numba_backend/_common.py
2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 |
|