std
"ALL"
)Compute the standard deviation of the elements of the vector x.
The standard deviation is defined as $$ {\rm std}(x) = \sqrt{{1\over N-1} \sum_{i=1}^N (x_i - \bar x )^2} $$
If x is an array, compute the standard deviation along the first non-singleton dimensions of x.
The optional argument w determines the weighting scheme to use. Valid values are:
Normalize with (population standard deviation). This provides the square root of the best unbiased estimator of the standard deviation.
Normalize with (sample standard deviation). This provides the square root of the second moment around the mean.
Compute the weighted standard deviation with non-negative weights. The length of w must equal the size of x in the operating dimension. NaN values are permitted in w, will be multiplied with the associated values in x, and can be excluded by the nanflag option.
Similar to vector weights, but w must be the same size as x. If
the operating dimension is supplied as vecdim or "all"
and
w is not a scalar, w must be an same-sized array.
Note: w must always be specified before specifying any of the following dimension options. To use the default value for w you may pass an empty input argument [].
The optional variable dim forces std
to operate over the
specified dimension, which must be a positive integer-valued number.
Specifying any singleton dimension in x, including any dimension
exceeding ndims (x)
, will result in a standard deviation of 0.
Specifying the dimensions as vecdim, a vector of non-repeating
dimensions, will return the standard deviation calculated over the array
slice defined by vecdim. If vecdim indexes all dimensions of
x, then it is equivalent to the option "all"
. Any
dimension in vecdim greater than ndims (x)
is ignored.
Specifying the dimension as "all"
will force std
to
operate on all elements of x, and is equivalent to
std (x(:))
.
The optional variable nanflag specifies whether to include or exclude
NaN values from the calculation using any of the previously specified input
argument combinations. The default value for nanflag is
"includenan"
which keeps NaN values in the calculation. To
exclude NaN values set the value of nanflag to "omitnan"
.
The output will still contain NaN values if x consists of all NaN
values in the operating dimension.
The optional second output variable m contains the mean of the elements of x used to calculate the standard deviation. If v is the weighted standard deviation, then m is also the weighted mean.
See also: var, bounds, mad, range, iqr, mean, median
Source Code: std