hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_5pt_summary (g01al)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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 xi and let zi, for i=1,2,,n, represent the sample observations sorted into ascending order.
Let m= n2  if n is even and n+1 2  if n is odd,
and k= m2  if m is even and m+1 2  if m is odd.
Then we have
Minimum =z1,  
Maximum =zn,  
Median =zm if n is odd,
  = zm+zm+12 if n is even, 12
Lower hinge =zk if m is odd,
  = zk+zk+12 if m is even, 12
Upper hinge =zn-k+1 if m is odd,
  = zn-k+zn-k+12 if m is even. 12

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:     xn – double array
The sample observations, x1,x2,,xn.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the array x.
n, number of observations in the sample.
Constraint: n5.

Output Parameters

1:     res5 – double array
res contains the five-point summary.
res1
The minimum.
res2
The lower hinge.
res3
The median.
res4
The upper hinge.
res5
The maximum.
2:     ifail int64int32nag_int scalar
ifail=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
On entry,n<5.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The computations are stable.

Further Comments

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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

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