Statistics: std

### Function Reference: `std`

statistics: s = std (x)
statistics: s = std (x, w)
statistics: s = std (x, w, "all")
statistics: s = std (x, w, dim)
statistics: s = std (x, w, vecdim)
statistics: s = std (…, nanflag)
statistics: [s, m] = std (…)

Compute the standard deviation of the elements of x.

- If x is a vector, then `std (x)` returns the standard deviation of the elements in x defined as $$ {\rm std}(x) = \sqrt{{1\over N-1} \sum_{i=1}^N |x_i - \bar x |^2} $$ where N is the length of the x vector.
- If x is a matrix, then `std (x)` returns a row vector with the standard deviation of each column in x.
- If x is a multi-dimensional array, then `std (x)` operates along the first non-singleton dimension of x.

`std (x, w)` specifies a weighting scheme. When w = 0 (default), the standard deviation is normalized by N-1 (population standard deviation), where N is the number of observations. When w = 1, the standard deviation is normalized by the number of observations (sample standard deviation). To use the default value you may pass an empty input argument [] before entering other options.

w can also be an array of non-negative numbers. When w is a vector, it must have the same length as the number of elements in the operating dimension of x. If w is a matrix or n-D array, or the operating dimension is supplied as a vecdim or "all", w must be the same size as x. NaN values are permitted in w, will be multiplied with the associated values in x, and can be excluded by the nanflag option.

`std (x, [], dim)` returns the standard deviation along the operating dimension dim of x. For dim greater than `ndims (x)`, then s is returned as zeros of the same size as x and m = x.

`std (x, [], vecdim)` returns the standard deviation over the dimensions specified in the vector vecdim. For example, if x is a 2-by-3-by-4 array, then `var (x, [1 2])` returns a 1-by-1-by-4 array. Each element of the output array is the standard deviation of the elements on the corresponding page of x. If vecdim indexes all dimensions of x, then it is equivalent to `std (x, "all")`. Any dimension in vecdim greater than `ndims (x)` is ignored.

`std (x, "all")` returns the standard deviation of all the elements in x. The optional flag "all" cannot be used together with dim or vecdim input arguments.

`std (…, nanflag)` specifies whether to exclude NaN values from the calculation using any of the input argument combinations in previous syntaxes. The default value for nanflag is "includenan", and keeps NaN values in the calculation. To exclude NaN values, set the value of nanflag to "omitnan".

`[s, m] = std (…)` also returns the mean of the elements of x used to calculate the standard deviation. If s is the weighted standard deviation, then m is the weighted mean.

See also: var, mean

Source Code: std