var
Calculates the variance 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 variances are computed.
By default, the variance is computed over the entire array.
If a tuple of integers, variances are computed over multiple axes. Default: |
None
|
|
correction
|
degrees of freedom adjustment. Setting this parameter to a value other than |
0.0
|
|
keepdims
|
if |
False
|
Returns:
Name | Type | Description |
---|---|---|
out |
array
|
if the variance was computed over the entire array, a zero-dimensional array containing the variance;
otherwise, a non-zero-dimensional array containing the variances.
The returned array must have the same data type as |
Special Cases
Let N
equal the number of elements over which to compute the variance.
- If
N - correction
is less than or equal to0
, the variance isNaN
. - If
x_i
isNaN
, the variance isNaN
(i.e.,NaN
values propagate).
Examples:
>>> a = sparse.COO.from_numpy(np.array([[0, 2], [-1, 1]]))
>>> o = sparse.var(a, axis=1)
>>> o.todense()
array([1., 1.])
Source code in sparse/numba_backend/_common.py
2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 |
|