mindspore.numpy.nanstd
- mindspore.numpy.nanstd(a, axis=None, dtype=None, ddof=0, keepdims=False)[源代码]
Computes the standard deviation along the specified axis, while ignoring NaNs.
Returns the standard deviation, a measure of the spread of a distribution, of the non-NaN array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis.
说明
Numpy arguments out is not supported. On GPU, the supported dtypes are np.float16, and np.float32.
- 参数
a (Union[int, float, list, tuple, Tensor]) – Calculates the standard deviation of the non-NaN values.
axis (Union[int, tuple of int, None], optional) – Axis or axes along which the standard deviation is computed. The default is to compute the standard deviation of the flattened array.
dtype (
mindspore.dtype
, optional) – Defaults to None. Overrides the dtype of the output Tensor.ddof (int, optional) – “Delta Degrees of Freedom”: the divisor used in the calculation is
N - ddof
, where N represents the number of non-NaN elements. By default ddof is zero.keepdims (boolean, optional) – Defaults to False. If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.
- 返回
Tensor.
- 异常
ValueError – If axes are out of the range of
[-a.ndim, a.ndim)
, or if the axes contain duplicates.
- Supported Platforms:
GPU
CPU
样例
>>> import mindspore.numpy as np >>> a = np.array([[1, np.nan], [3, 4]]) >>> output = np.nanstd(a) >>> print(output) 1.2472192 >>> output = np.nanstd(a, axis=0) >>> print(output) [1. 0.] >>> output = np.nanstd(a, axis=1) >>> print(output) [0. 0.5]