Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_5pt_summary (g01al)

Purpose

nag_stat_5pt_summary (g01al) calculates a five-point summary for a single sample.

Syntax

[res, ifail] = g01al(x, 'n', n)
[res, ifail] = nag_stat_5pt_summary(x, 'n', n)

Description

nag_stat_5pt_summary (g01al) calculates the minimum, lower hinge, median, upper hinge and the maximum of a sample of n$n$ observations.
The data consist of a single sample of n$n$ observations denoted by xi${x}_{i}$ and let zi${z}_{i}$, for i = 1,2,,n$i=1,2,\dots ,n$, represent the sample observations sorted into ascending order.
Let m = n/2 $m=\frac{n}{2}$ if n$n$ is even and ((n + 1))/2 $\frac{\left(n+1\right)}{2}$ if n$n$ is odd,
and k = m/2 $k=\frac{m}{2}$ if m$m$ is even and ((m + 1))/2 $\frac{\left(m+1\right)}{2}$ if m$m$ is odd.
Then we have
 Minimum = z1$\text{}={z}_{1}$, Maximum = zn$\text{}={z}_{n}$, Median = zm$\text{}={z}_{m}$ if n$n$ is odd, = (zm + zm + 1)/2 $\text{}=\frac{{z}_{m}+{z}_{m+1}}{2}$ if n$n$ is even, (1/2)$\phantom{\frac{1}{2}}$ Lower hinge = zk$\text{}={z}_{k}$ if m$m$ is odd, = (zk + zk + 1)/2 $\text{}=\frac{{z}_{k}+{z}_{k+1}}{2}$ if m$m$ is even, (1/2)$\phantom{\frac{1}{2}}$ Upper hinge = zn − k + 1$\text{}={z}_{n-k+1}$ if m$m$ is odd, = (zn − k + zn − k + 1)/2 $\text{}=\frac{{z}_{n-k}+{z}_{n-k+1}}{2}$ if m$m$ is even.(1/2)$\phantom{\frac{1}{2}}$

References

Erickson B H and Nosanchuk T A (1985) Understanding Data Open University Press, Milton Keynes
Tukey J W (1977) Exploratory Data Analysis Addison–Wesley

Parameters

Compulsory Input Parameters

1:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n5${\mathbf{n}}\ge 5$.
The sample observations, x1,x2,,xn${x}_{1},{x}_{2},\dots ,{x}_{n}$.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array x.
n$n$, number of observations in the sample.
Constraint: n5${\mathbf{n}}\ge 5$.

iwrk

Output Parameters

1:     res(5$5$) – double array
res contains the five-point summary.
res(1)${\mathbf{res}}\left(1\right)$
The minimum.
res(2)${\mathbf{res}}\left(2\right)$
The lower hinge.
res(3)${\mathbf{res}}\left(3\right)$
The median.
res(4)${\mathbf{res}}\left(4\right)$
The upper hinge.
res(5)${\mathbf{res}}\left(5\right)$
The maximum.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 5${\mathbf{n}}<5$.

Accuracy

The computations are stable.

The time taken by nag_stat_5pt_summary (g01al) is proportional to n$n$.

Example

```function nag_stat_5pt_summary_example
x = [12;
9;
2;
5;
6;
8;
2;
7;
3;
1;
11;
10];
[res, ifail] = nag_stat_5pt_summary(x)
```
```

res =

1.0000
2.5000
6.5000
9.5000
12.0000

ifail =

0

```
```function g01al_example
x = [12;
9;
2;
5;
6;
8;
2;
7;
3;
1;
11;
10];
[res, ifail] = g01al(x)
```
```

res =

1.0000
2.5000
6.5000
9.5000
12.0000

ifail =

0

```