The median is the 'middle' value from a set of values. If the number of values is an even number, the median is the mean of the 'middle' values.
The median is generally used in programming in the sense of the term that comes from statistics. In simple terms it means the number that has half the values above it and half the values below it in the range. It is different than average in that an average can be influenced by extremes on either end of the spectrum. If a few numbers are a lot greater or a lot smaller than the rest, the average will be significantly different from the median. Median can give you a better sense of where the typical middle case is than the average.
The median is also very useful in signal and image processing, in the context of a moving median filter. This filter is usually used to reduce "salt and pepper" type noise, as well as spikes, because each output pixel or element contains the median value of the m-by-n neighborhood around that corresponding pixel in the data.
For a more statistically and technically correct and thorough explanation, see Wikipedia.
In scientific software r for statistical computing and graphics, the median of a numeric vector can be found by function median
, or quantile
with prob = 0.5
.