Navigation

Operators and Keywords

Function List:

C++ API

: median (x)
: median (x, dim)

Compute the median value of the elements of the vector x.

When the elements of x are sorted, the median is defined as

              x(ceil(N/2))             N odd
median (x) =
             (x(N/2) + x((N/2)+1))/2   N even

If x is of a discrete type such as integer or logical, then the case of even N rounds up (or toward true).

If x is a matrix, compute the median value for each column and return them in a row vector.

If the optional dim argument is given, operate along this dimension.

See also: mean, mode.

Package: octave