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
Description
The data consists of a sample of size , denoted by , drawn from a random variable .
nag_univar_robust_1var_median (g07da) first computes the median,
and from this the median absolute deviation can be computed,
Finally, a robust estimate of the standard deviation is computed,
where
is the value of the inverse standard Normal function at the point
.
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:
– double array
-
The vector of observations, .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
, the number of observations.
Constraint:
.
Output Parameters
- 1:
– double array
-
The observations sorted into ascending order.
- 2:
– double scalar
-
The median, .
- 3:
– double scalar
-
The median absolute deviation, .
- 4:
– double scalar
-
The robust estimate of the standard deviation, .
- 5:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The computations are believed to be stable.
Further Comments
None.
Example
The following program reads in a set of data consisting of eleven observations of a variable
. The median, median absolute deviation and a robust estimate of the standard deviation are calculated and printed along with the sorted data in output array
y.
Open in the MATLAB editor:
g07da_example
function g07da_example
fprintf('g07da example results\n\n');
x = [13; 11; 16; 5; 3; 18; 9; 8; 6; 27; 7];
fprintf('Original Data\n ');
fprintf('%7.3f',x)
fprintf('\n\n');
[y, xme, xmd, xsd, ifail] = g07da(x);
fprintf('Sorted Data\n ');
fprintf('%7.3f',y)
fprintf('\n\n');
fprintf('Median = %6.3f\n', xme);
fprintf('Median absolute deviation = %6.3f\n', xmd);
fprintf('Robust estimate standard deviation = %6.3f\n', xsd);
g07da example results
Original Data
13.000 11.000 16.000 5.000 3.000 18.000 9.000 8.000 6.000 27.000 7.000
Sorted Data
3.000 5.000 6.000 7.000 8.000 9.000 11.000 13.000 16.000 18.000 27.000
Median = 9.000
Median absolute deviation = 4.000
Robust estimate standard deviation = 5.930
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015