Standard deviation of a data sample

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


stats::stdev(x1, x2, …, <Sample | Population>)
stats::stdev([x1, x2, …], <Sample | Population>)
stats::stdev(s, <c>, <Sample | Population>)


stats::stdev( x1, x2, ..., xn) returns the standard deviation


where is the arithmetic mean of the data xi.

stats::stdev( x1, x2, ..., xn, Population) returns


The standard deviation is the square root of the variance.

The column index c is optional, if the data are given by a stats::sample object containing only one non-string column. Cf. Example 3.

External statistical data stored in an ASCII file can be imported into a MuPAD® session via import::readdata. In particular, see Example 1 of the corresponding help page.


Example 1

We calculate the standard deviation of three values:

stats::stdev(2, 3, 5)

Alternatively, the data may be passed as a list:

stats::stdev([2, 3, 5])

Example 2

We create a sample:

stats::sample([[a1, b1, c1], [a2, b2, c2]])
a1  b1  c1
a2  b2  c2

The standard deviation of the second column is:

expand(stats::stdev(%, 2))

Example 3

We create a sample consisting of one string column and one non-string column:

stats::sample([["1996", 1242], ["1997", 1353], ["1998", 1142]])
"1996"  1242
"1997"  1353
"1998"  1142

We compute the standard deviation of the second column. In this case this column does not have to be specified, since it is the only non-string column:


We repeat the computation with the option Population:

float(stats::stdev(%2, Population))


x1, x2, …

The statistical data: arithmetical expressions


A sample of domain type stats::sample


An integer representing a column index of the sample s. This column provides the data x1, x2 etc.


Population, Sample

With Sample, the data are regarded as a “sample”, not as a full population. The default is Sample.

Return Values

Arithmetical expression.