## `stats::stdev` -- the standard deviation

#### Introduction

`stats::stdev``(data)` returns the standard deviation of the data.

#### Call(s)

`stats::stdev(x1, x2, .. <, Sample>)`
`stats::stdev([x1, x2, ..] <, Sample>)`
`stats::stdev(s <, c> <, Sample>)`

#### Parameters

`x1, x2, ..` | - | the statistical data: arithmetical expressions.
`s` | - | a sample of domain type `stats::sample`.
`c` | - | an integer representing a column index of the sample `s`. This column provides the data `x1`, `x2` etc.

#### Options

`Sample` | - | with this option the given data are regarded as a ``sample'', not as a full population.

#### Returns

an arithmetical expression.

#### Related Functions

`stats::a_quantil`, `stats::geometric`, `stats::harmonic`, `stats::mean`, `stats::median`, `stats::modal`, `stats::quadratic`, `stats::variance`

#### Details

- The standard deviation of n values x[1],..,x[n] is (1/n*((x[n]-X)^2 + .. + (x[n]-X)^2))^(1/2), where X is the arithmetic mean of the x[i]. It is the square-root of the variance. With the option Sample the value (1/(n-1)*((x[n]-X)^2 + .. + (x[n]-X)^2))^(1/2) is returned instead.
- 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.

#### Example 1

We calculate the standard deviation of three values:

    >> stats::stdev(2, 3, 5)

                                         1/2
                                       14
                                       -----
                                         3

Alternatively, the data may be passed as a list:

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

                                         1/2
                                       14
                                       -----
                                         3

#### 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))

                             /   2             2 \1/2
                             | b1    b1 b2   b2  |
                             | --- - ----- + --- |
                             \  4      2      4  /

#### 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:

    >> float(stats::stdev(%))

                                    86.17939945

We repeat the computation with the option Sample:

    >> float(stats::stdev(%2, Sample))

                                    105.5477775

#### Changes

- The input data can now be provided by a `stats::sample`.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000