## `stats::a_quantil` -- alpha-quantile of discrete data

#### Introduction

`stats::a_quantil``(a, ..)` returns the alpha-quantile of discrete data.

#### Call(s)

`stats::a_quantil(a, x1, x2, ..)`
`stats::a_quantil(a, [x1, x2, ..])`
`stats::a_quantil(a, s <, c>)`

#### Parameters

`a` | - | the alpha value: a rational number or a real float from the interval (0,1).
`x1, x2, ..` | - | the statistical data: real numerical values.
`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.

#### Returns

an arithmetical expression. `FAIL` is returned, if the data are empty.

#### Related Functions

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

#### Details

- The alpha-quantile of n sorted values x[1]<= .. <= x[n] is (x[k] + x[k+1])/2, if k:= n*alpha is an integer. If k is not an integer, then the alpha-quantile is the data element x[ceil(k)], where `ceil`(k) is the next integer larger than k.
- The data do not have to be sorted on input: `stats::a_quantil` sorts internally.
- The data must be real and numerical. Expressions such as `PI + sqrt(2)`, `exp(-5)` etc. are converted to floating point numbers.
- 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.
- The 1/2-quantile is called median. This special quantile is implemented in `stats::median`.

#### Example 1

We calculate the 1/4-quantile of a sequence of five values:

    >> stats::a_quantil(1/4, 3, 8, 5, 9/2, 11)

                                        9/2

Alternatively, the data may be passed as a list:

    >> stats::a_quantil(1/4, [3, 8, 5, 9/2, 11])

                                        9/2

#### Example 2

We create a sample:

    >> stats::sample([[4, 7, 5], [3, 6, 17], [8, 2, 2]])

                                    4  7   5
                                    3  6  17
                                    8  2   2

The 1/2-quantile (the `median`) of the second column is calculated:

    >> stats::a_quantil(1/2, %, 2)

                                         6

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

The 0.3-quantile of the second column is calculated. In this case this column does not have to be specified, since it is the only non-string column in the sample:

    >> stats::a_quantil(0.3, %)

                                       1142

#### Changes

- new function

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