SciPy

scipy.stats.nanstd

scipy.stats.nanstd(x, axis=0, bias=False)[source]

Compute the standard deviation over the given axis, ignoring nans.

Parameters :

x : array_like

Input array.

axis : int or None, optional

Axis along which the standard deviation is computed. Default is 0. If None, compute over the whole array x.

bias : bool, optional

If True, the biased (normalized by N) definition is used. If False (default), the unbiased definition is used.

Returns :

s : float

The standard deviation.

See also

nanmean, nanmedian

Examples

>>> from scipy import stats
>>> a = np.arange(10, dtype=float)
>>> a[1:3] = np.nan
>>> np.std(a)
nan
>>> stats.nanstd(a)
2.9154759474226504
>>> stats.nanstd(a.reshape(2, 5), axis=1)
array([ 2.0817,  1.5811])
>>> stats.nanstd(a.reshape(2, 5), axis=None)
2.9154759474226504

Previous topic

scipy.stats.nanmean

Next topic

scipy.stats.nanmedian