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)

# NAG Toolbox: nag_univar_robust_1var_median (g07da)

## Purpose

nag_univar_robust_1var_median (g07da) finds the median, median absolute deviation, and a robust estimate of the standard deviation for a set of ungrouped data.

## Syntax

[y, xme, xmd, xsd, ifail] = g07da(x, 'n', n)
[y, xme, xmd, xsd, ifail] = nag_univar_robust_1var_median(x, 'n', n)

## Description

The data consists of a sample of size n$n$, denoted by x1,x2,,xn${x}_{1},{x}_{2},\dots ,{x}_{n}$, drawn from a random variable X$X$.
nag_univar_robust_1var_median (g07da) first computes the median,
 θmed = medi{xi}, $θmed=medi {xi} ,$
and from this the median absolute deviation can be computed,
 σmed = medi{|xi − θmed|}. $σmed=medi { |xi-θmed| } .$
Finally, a robust estimate of the standard deviation is computed,
 σmed ′ = σmed / Φ − 1(0.75) $σmed′=σmed/Φ-1 (0.75)$
where Φ1(0.75)${\Phi }^{-1}\left(0.75\right)$ is the value of the inverse standard Normal function at the point 0.75$0.75$.
nag_univar_robust_1var_median (g07da) is based upon function LTMDDV within the ROBETH library, see Marazzi (1987).

## References

Huber P J (1981) Robust Statistics Wiley
Marazzi A (1987) Subroutines for robust estimation of location and scale in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 1 Institut Universitaire de Médecine Sociale et Préventive, Lausanne

## Parameters

### Compulsory Input Parameters

1:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n > 1${\mathbf{n}}>1$.
The vector of 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$, the number of observations.
Constraint: n > 1${\mathbf{n}}>1$.

None.

### Output Parameters

1:     y(n) – double array
The observations sorted into ascending order.
2:     xme – double scalar
The median, θmed${\theta }_{\mathrm{med}}$.
3:     xmd – double scalar
The median absolute deviation, σmed${\sigma }_{\mathrm{med}}$.
4:     xsd – double scalar
The robust estimate of the standard deviation, σmed${\sigma }_{\mathrm{med}}^{\prime }$.
5:     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 ≤ 1${\mathbf{n}}\le 1$.

## Accuracy

The computations are believed to be stable.

None.

## Example

```function nag_univar_robust_1var_median_example
x = [13;
11;
16;
5;
3;
18;
9;
8;
6;
27;
7];
[y, xme, xmd, xsd, ifail] = nag_univar_robust_1var_median(x)
```
```

y =

3
5
6
7
8
9
11
13
16
18
27

xme =

9

xmd =

4

xsd =

5.9304

ifail =

0

```
```function g07da_example
x = [13;
11;
16;
5;
3;
18;
9;
8;
6;
27;
7];
[y, xme, xmd, xsd, ifail] = g07da(x)
```
```

y =

3
5
6
7
8
9
11
13
16
18
27

xme =

9

xmd =

4

xsd =

5.9304

ifail =

0

```

PDF version (NAG web site, 64-bit version, 64-bit version)

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