MCPcopy Index your code
hub / github.com/numpy/numpy / nanvar

Function nanvar

numpy/lib/_nanfunctions_impl.py:1694–1874  ·  view source on GitHub ↗

Compute the variance along the specified axis, while ignoring NaNs. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis. For all-NaN slices or sli

(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue,
           *, where=np._NoValue, mean=np._NoValue, correction=np._NoValue)

Source from the content-addressed store, hash-verified

1692
1693@array_function_dispatch(_nanvar_dispatcher)
1694def nanvar(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue,
1695 *, where=np._NoValue, mean=np._NoValue, correction=np._NoValue):
1696 """
1697 Compute the variance along the specified axis, while ignoring NaNs.
1698
1699 Returns the variance of the array elements, a measure of the spread of
1700 a distribution. The variance is computed for the flattened array by
1701 default, otherwise over the specified axis.
1702
1703 For all-NaN slices or slices with zero degrees of freedom, NaN is
1704 returned and a `RuntimeWarning` is raised.
1705
1706 Parameters
1707 ----------
1708 a : array_like
1709 Array containing numbers whose variance is desired. If `a` is not an
1710 array, a conversion is attempted.
1711 axis : {int, tuple of int, None}, optional
1712 Axis or axes along which the variance is computed. The default is to compute
1713 the variance of the flattened array.
1714 dtype : data-type, optional
1715 Type to use in computing the variance. For arrays of integer type
1716 the default is `float64`; for arrays of float types it is the same as
1717 the array type.
1718 out : ndarray, optional
1719 Alternate output array in which to place the result. It must have
1720 the same shape as the expected output, but the type is cast if
1721 necessary.
1722 ddof : {int, float}, optional
1723 "Delta Degrees of Freedom": the divisor used in the calculation is
1724 ``N - ddof``, where ``N`` represents the number of non-NaN
1725 elements. By default `ddof` is zero.
1726 keepdims : bool, optional
1727 If this is set to True, the axes which are reduced are left
1728 in the result as dimensions with size one. With this option,
1729 the result will broadcast correctly against the original `a`.
1730 where : array_like of bool, optional
1731 Elements to include in the variance. See `~numpy.ufunc.reduce` for
1732 details.
1733
1734 .. versionadded:: 1.22.0
1735
1736 mean : array_like, optional
1737 Provide the mean to prevent its recalculation. The mean should have
1738 a shape as if it was calculated with ``keepdims=True``.
1739 The axis for the calculation of the mean should be the same as used in
1740 the call to this var function.
1741
1742 .. versionadded:: 2.0.0
1743
1744 correction : {int, float}, optional
1745 Array API compatible name for the ``ddof`` parameter. Only one of them
1746 can be provided at the same time.
1747
1748 .. versionadded:: 2.0.0
1749
1750 Returns
1751 -------

Callers 1

nanstdFunction · 0.85

Calls 8

_replace_nanFunction · 0.85
_divide_by_countFunction · 0.85
_copytoFunction · 0.85
varMethod · 0.45
dtypeMethod · 0.45
sumMethod · 0.45
squeezeMethod · 0.45
anyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…