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
2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 | |