Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 Group: Statistical Data Analysis Topic: Basic Statistics See also: mean sum var

 Function: median Description: Computes the empirical medians of a given array.

 Usage: median = median (x {, j}) Input: x d1 x d2 x .. x dn array j integer (for faster median, default 0) Output: median 1 x d2 x .. x dn array - for each column in x the empirical medians

Note:
The empirical median is computed as the central value of the order statistics in case of an odd number of observations, or the average of the two central values in case of an even number. NaN is returned for each column containing any NaN.

Any non-zero number as the optional parameter causes for even number of observations faster computing - the median is simply aproximated by the (# of elements)/2 th element (possible to use for samples greater than 100 only).

Example:
```randomize(0)
x = normal(200, 3)
median(x)

```
Result:
```Contents of median
[1,] -0.063414 -0.040036  0.062863
```
Example:
```randomize(0)
x = normal(200, 3)
x[1,1:2] = NaN
x[2,1] = NaN
median(x)

```
Result:
```Contents of median
[1,]     +NAN     +NAN  0.062863
```

(C) MD*TECH Method and Data Technologies, 05.02.2006