# scipp.std#

scipp.std(x, dim=None, *, ddof)#

Compute the standard deviation of the input values.

This function computes the standard deviation of the input values which is not related to the x.variances property but instead defined as

$\mathsf{std}(x)^2 = \frac1{N - \mathsf{ddof}} \sum_{i=1}^{N}\, {(x_i - \bar{x})}^2$

where $$x_i$$ are the unmasked values of the input and $$\bar{x}$$ is the mean, see scipp.mean(). See the ddof parameter description for what value to choose.

Note

Masks are broadcast to the shape of x. This can lead to a large temporary memory usage.

Parameters:
Returns:

Same type as x – The standard deviation of the input values.

Raises:

scipp.stddevs

Compute the standard deviations from the stored variances of a scipp.Variable.

scipp.mean

Compute the arithmetic mean.

scipp.var

Compute the variance.

scipp.nanstd

Ignore NaN’s when calculating the standard deviation.

Examples

std is available as a method:

>>> x = sc.array(dims=['x'], values=[3, 5, 2, 3])
>>> x.std(ddof=0)
<scipp.Variable> ()    float64  [dimensionless]  1.08972
>>> x.std(ddof=1)
<scipp.Variable> ()    float64  [dimensionless]  1.25831


Select a dimension to reduce:

>>> x = sc.array(dims=['x', 'y'], values=[[1, 3, 6], [2, 7, 4]])
>>> x.std('y', ddof=0)
<scipp.Variable> (x: 2)    float64  [dimensionless]  [2.0548, 2.0548]
>>> x.std('x', ddof=0)
<scipp.Variable> (y: 3)    float64  [dimensionless]  [0.5, 2, 1]