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$ observations.
The data consist of a single sample of $n$ observations denoted by ${x}_{i}$ and let ${z}_{i}$, for $i=1,2,\dots ,n$, represent the sample observations sorted into ascending order.
Let $m=\frac{n}{2}$ if $n$ is even and $\frac{\left(n+1\right)}{2}$ if $n$ is odd,
and $k=\frac{m}{2}$ if $m$ is even and $\frac{\left(m+1\right)}{2}$ if $m$ is odd.
Then we have
 Minimum $\text{}={z}_{1}$, Maximum $\text{}={z}_{n}$, Median $\text{}={z}_{m}$ if $n$ is odd, $\text{}=\frac{{z}_{m}+{z}_{m+1}}{2}$ if $n$ is even, $\phantom{\frac{1}{2}}$ Lower hinge $\text{}={z}_{k}$ if $m$ is odd, $\text{}=\frac{{z}_{k}+{z}_{k+1}}{2}$ if $m$ is even, $\phantom{\frac{1}{2}}$ Upper hinge $\text{}={z}_{n-k+1}$ if $m$ is odd, $\text{}=\frac{{z}_{n-k}+{z}_{n-k+1}}{2}$ if $m$ is even.$\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:     $\mathrm{x}\left({\mathbf{n}}\right)$ – double array
The sample observations, ${x}_{1},{x}_{2},\dots ,{x}_{n}$.

### Optional Input Parameters

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

### Output Parameters

1:     $\mathrm{res}\left(5\right)$ – double array
res contains the five-point summary.
${\mathbf{res}}\left(1\right)$
The minimum.
${\mathbf{res}}\left(2\right)$
The lower hinge.
${\mathbf{res}}\left(3\right)$
The median.
${\mathbf{res}}\left(4\right)$
The upper hinge.
${\mathbf{res}}\left(5\right)$
The maximum.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{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:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{n}}<5$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

The computations are stable.

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

## Example

This example calculates a five-point summary for a sample of $12$ observations.
```function g01al_example

fprintf('g01al example results\n\n');

x = [12     9     2     5     6     8 ...
2     7     3     1    11    10];

[res, ifail] = g01al(x);

fprintf('Maximum                    %14.4f\n', res(5));
fprintf('Upper Hinge (75%% quantile) %14.4f\n', res(4));
fprintf('Median      (50%% quantile) %14.4f\n', res(3));
fprintf('Lower Hinge (25%% quantile) %14.4f\n', res(2));
fprintf('Minimum                    %14.4f\n', res(1));

```
```g01al example results

Maximum                           12.0000
Upper Hinge (75% quantile)         9.5000
Median      (50% quantile)         6.5000
Lower Hinge (25% quantile)         2.5000
Minimum                            1.0000
```

Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015