# Median

{{#invoke:Hatnote|hatnote}} Template:Distinguish

In statistics and probability theory, the median is the numerical value separating the higher half of a data sample, a population, or a probability distribution, from the lower half. The median of a finite list of numbers can be found by arranging all the observations from lowest value to highest value and picking the middle one (e.g., the median of {3, 3, 5, 9, 11} is 5). If there is an even number of observations, then there is no single middle value; the median is then usually defined to be the mean of the two middle values [1] [2] (the median of {3, 5, 7, 9} is (5 + 7) / 2 = 6), which corresponds to interpreting the median as the fully trimmed mid-range. The median is of central importance in robust statistics, as it is the most resistant statistic, having a breakdown point of 50%: so long as no more than half the data is contaminated, the median will not give an arbitrarily large result. A median is only defined on ordered one-dimensional data, and is independent of any distance metric. A geometric median, on the other hand, is defined in any number of dimensions.

In a sample of data, or a finite population, there may be no member of the sample whose value is identical to the median (in the case of an even sample size); if there is such a member, there may be more than one so that the median may not uniquely identify a sample member. Nonetheless, the value of the median is uniquely determined with the usual definition. A related concept, in which the outcome is forced to correspond to a member of the sample, is the medoid. At most, half the population have values strictly less than the median, and, at most, half have values strictly greater than the median. If each group contains less than half the population, then some of the population is exactly equal to the median. For example, if a < b < c, then the median of the list {abc} is b, and, if a < b < c < d, then the median of the list {abcd} is the mean of b and c; i.e., it is (b + c)/2.

The median can be used as a measure of location when a distribution is skewed, when end-values are not known, or when one requires reduced importance to be attached to outliers, e.g., because they may be measurement errors.

In terms of notation, some authors represent the median of a variable x either as ${\displaystyle {\tilde {x}}}$ or as ${\displaystyle \mu _{1/2},}$[1] sometimes also M.[3] There is no widely accepted standard notation for the median,[4] so the use of these or other symbols for the median needs to be explicitly defined when they are introduced.

The median is the 2nd quartile, 5th decile, and 50th percentile.

## Measures of location and dispersion

The median is one of a number of ways of summarising the typical values associated with members of a statistical population; thus, it is a possible location parameter. Since the median is the same as the second quartile, its calculation is illustrated in the article on quartiles.

When the median is used as a location parameter in descriptive statistics, there are several choices for a measure of variability: the range, the interquartile range, the mean absolute deviation, and the median absolute deviation.

For practical purposes, different measures of location and dispersion are often compared on the basis of how well the corresponding population values can be estimated from a sample of data. The median, estimated using the sample median, has good properties in this regard. While it is not usually optimal if a given population distribution is assumed, its properties are always reasonably good. For example, a comparison of the efficiency of candidate estimators shows that the sample mean is more statistically efficient than the sample median when data are uncontaminated by data from heavy-tailed distributions or from mixtures of distributions, but less efficient otherwise, and that the efficiency of the sample median is higher than that for a wide range of distributions. More specifically, the median has a 64% efficiency compared to the minimum-variance mean (for large normal samples), which is to say the variance of the median will be ~50% greater than the variance of the mean—see Efficiency (statistics)#Asymptotic efficiency and references therein.

## Probability distributions

For any probability distribution on the real line R with cumulative distribution function F, regardless of whether it is any kind of continuous probability distribution, in particular an absolutely continuous distribution (which has a probability density function), or a discrete probability distribution, a median is by definition any real number m that satisfies the inequalities

${\displaystyle \operatorname {P} (X\leq m)\geq {\frac {1}{2}}{\text{ and }}\operatorname {P} (X\geq m)\geq {\frac {1}{2}}\,\!}$

or, equivalently, the inequalities

${\displaystyle \int _{(-\infty ,m]}dF(x)\geq {\frac {1}{2}}{\text{ and }}\int _{[m,\infty )}dF(x)\geq {\frac {1}{2}}\,\!}$

in which a Lebesgue–Stieltjes integral is used. For an absolutely continuous probability distribution with probability density function ƒ, the median satisfies

${\displaystyle \operatorname {P} (X\leq m)=\operatorname {P} (X\geq m)=\int _{-\infty }^{m}f(x)\,dx={\frac {1}{2}}.\,\!}$

Any probability distribution on R has at least one median, but there may be more than one median. Where exactly one median exists, statisticians speak of "the median" correctly; even when the median is not unique, some statisticians speak of "the median" informally.

### Medians of particular distributions

The medians of certain types of distributions can be easily calculated from their parameters:

• The median of a symmetric distribution with mean μ is μ.
• The median of a normal distribution with mean μ and variance σ2 is μ. In fact, for a normal distribution, mean = median = mode.
• The median of a uniform distribution in the interval [ab] is (a + b) / 2, which is also the mean.
• The median of a Cauchy distribution with location parameter x0 and scale parameter y is x0, the location parameter.
• The median of an exponential distribution with rate parameter λ is the natural logarithm of 2 divided by the rate parameter: λ−1ln 2.
• The median of a Weibull distribution with shape parameter k and scale parameter λ is λ(ln 2)1/k.

## Descriptive statistics

Comparison of mean, median and mode of two log-normal distributions with different skewness.

The median is used primarily for skewed distributions, which it summarizes differently from the arithmetic mean. Consider the multiset { 1, 2, 2, 2, 3, 14 }. The median is 2 in this case, (as is the mode), and it might be seen as a better indication of central tendency (less susceptible to the exceptionally large value in data) than the arithmetic mean of 4.

Calculation of medians is a popular technique in summary statistics and summarizing statistical data, since it is simple to understand and easy to calculate, while also giving a measure that is more robust in the presence of outlier values than is the mean.

## Populations

### Optimality property

The mean absolute error of a real variable c with respect to the random variable X is

${\displaystyle E(\left|X-c\right|)\,}$

Provided that the probability distribution of X is such that the above expectation exists, then m is a median of X if and only if m is a minimizer of the mean absolute error with respect to X.[5] In particular, m is a sample median if and only if m minimizes the arithmetic mean of the absolute deviations.

### Unimodal distributions

It can be shown for a unimodal distribution that the median ${\displaystyle {\tilde {X}}}$ and the mean ${\displaystyle {\bar {X}}}$ lie within (3/5)1/2 ≈ 0.7746 standard deviations of each other.[6] In symbols,

${\displaystyle {\frac {\left|{\tilde {X}}-{\bar {X}}\right|}{\sigma }}\leq (3/5)^{1/2}}$

where |.| is the absolute value.

A similar relation holds between the median and the mode: they lie within 31/2 ≈ 1.732 standard deviations of each other:

${\displaystyle {\frac {\left|{\tilde {X}}-\mathrm {mode} \right|}{\sigma }}\leq 3^{1/2}.}$

### Inequality relating means and medians

If the distribution has finite variance, then the distance between the median and the mean is bounded by one standard deviation.

This bound was proved by Mallows,[7] who used Jensen's inequality twice, as follows. We have

{\displaystyle {\begin{aligned}\left|\mu -m\right|=\left|\mathrm {E} (X-m)\right|&\leq \mathrm {E} \left(\left|X-m\right|\right)\\&\leq \mathrm {E} \left(\left|X-\mu \right|\right)\\&\leq {\sqrt {\mathrm {E} ((X-\mu )^{2})}}=\sigma .\end{aligned}}}

The first and third inequalities come from Jensen's inequality applied to the absolute-value function and the square function, which are each convex. The second inequality comes from the fact that a median minimizes the absolute deviation function

${\displaystyle a\mapsto \mathrm {E} (\left|X-a\right|).\,}$

This proof can easily be generalized to obtain a multivariate version of the inequality,[8] as follows:

{\displaystyle {\begin{aligned}\left\|\mu -m\right\|=\left\|\mathrm {E} (X-m)\right\|&\leq \mathrm {E} \|X-m\|\\&\leq \mathrm {E} (\left\|X-\mu \right\|)\\&\leq {\sqrt {\mathrm {E} (\|X-\mu \|^{2})}}={\sqrt {\mathrm {trace} (\mathrm {var} (X))}}\end{aligned}}}

where m is a spatial median, that is, a minimizer of the function ${\displaystyle a\mapsto \mathrm {E} (\left\|X-a\right\|).\,}$ The spatial median is unique when the data-set's dimension is two or more.[9][10] An alternative proof uses the one-sided Chebyshev inequality; it appears in an inequality on location and scale parameters.

## Jensen's inequality for medians

Jensen's inequality states that for any random variable x with a ﬁnite expectation E(x) and for any convex function f

${\displaystyle f(E(x))\leq E(f(x))}$

It has been shown[11] that if x is a real variable with a unique median m and f is a C function then

${\displaystyle f(m)\leq \operatorname {Median} (f(x))}$

A C function is a real valued function, defined on the set of real numbers R, with the property that for any real t

${\displaystyle f^{-1}((-\infty ,t])=\{x\in R|f(x)\leq t\}}$

is a closed interval, a singleton or an empty set.

## Medians for samples

### The sample median

#### Efficient computation of the sample median

Even though comparison-sorting n items requires Ω(n log n) operations, selection algorithms can compute the kth-smallest of n items with only Θ(n) operations. This includes the median, which is the (n/2)th order statistic (or for an even number of samples, the average of the two middle order statistics).

#### Easy explanation of the sample median

In individual series (if number of observation is very low) first one must arrange all the observations in order. Then count(n) is the total number of observation in given data.

If n is odd then Median (M) = value of ((n + 1)/2)th item term.

If n is even then Median (M) = value of [((n)/2)th item term + ((n)/2 + 1)th item term ]/2

For an odd number of values

As an example, we will calculate the sample median for the following set of observations: 1, 5, 2, 8, 7.

Start by sorting the values: 1, 2, 5, 7, 8.

In this case, the median is 5 since it is the middle observation in the ordered list.

The median is the ((n + 1)/2)th item, where n is the number of values. For example, for the list {1, 2, 5, 7, 8}, we have n = 5, so the median is the ((5 + 1)/2)th item.

median = (6/2)th item
median = 3rd item
median = 5
For an even number of values

As an example, we will calculate the sample median for the following set of observations: 1, 6, 2, 8, 7, 2.

Start by sorting the values: 1, 2, 2, 6, 7, 8.

In this case, the arithmetic mean of the two middlemost terms is (2 + 6)/2 = 4. Therefore, the median is 4 since it is the arithmetic mean of the middle observations in the ordered list.

We also use this formula MEDIAN = {(n + 1 )/2}th item . n = number of values

As above example 1, 2, 2, 6, 7, 8 n = 6 Median = {(6 + 1)/2}th item = 3.5th item. In this case, the median is average of the 3rd number and the next one (the fourth number). The median is (2 + 6)/2 which is 4.

#### Variance

The distribution of both the sample mean and the sample median were determined by Laplace.[12] The distribution of the sample median from a population with a density function ${\displaystyle f(x)}$ is asymptotically normal with mean ${\displaystyle m}$ and variance[13]

${\displaystyle {\frac {1}{4nf(m)^{2}}}}$

where ${\displaystyle m}$ is the median value of distribution and ${\displaystyle n}$ is the sample size. In practice this may be difficult to estimate as the density function is usually unknown.

These results have also been extended.[14] It is now known for the ${\displaystyle p}$-th quantile that the distribution of the sample ${\displaystyle p}$-th quantile is asymptotically normal around the ${\displaystyle p}$-th quantile with variance equal to

${\displaystyle {\frac {p(1-p)}{nf(x_{p})^{2}}}}$

where ${\displaystyle f(x_{p})}$ is the value of the distribution density at the ${\displaystyle p}$-th quantile.

Estimation of variance from sample data

The value of ${\displaystyle (2f(x))^{-2}}$—the asymptotic value of ${\displaystyle n^{-{\frac {1}{2}}}(\nu -m)}$ where ${\displaystyle \nu }$ is the population median—has been studied by several authors. The standard 'delete one' jackknife method produces inconsistent results.[15] An alternative—the 'delete k' method—where ${\displaystyle k}$ grows with the sample size has been shown to be asymptotically consistent.[16] This method may be computationally expensive for large data sets. A bootstrap estimate is known to be consistent,[17] but converges very slowly (order of ${\displaystyle n^{-{\frac {1}{4}}}}$).[18] Other methods have been proposed but their behavior may differ between large and small samples.[19]

Efficiency

The efficiency of the sample median, measured as the ratio of the variance of the mean to the variance of the median, depends on the sample size and on the underlying population distribution. For a sample of size ${\displaystyle N=2n+1}$ from the normal distribution, the ratio is[20]

${\displaystyle {\frac {4n}{\pi (2n+1)}}}$

For large samples (as ${\displaystyle n}$ tends to infinity) this ratio tends to ${\displaystyle {\frac {2}{\pi }}.}$

### Other estimators

For univariate distributions that are symmetric about one median, the Hodges–Lehmann estimator is a robust and highly efficient estimator of the population median.[21]

### Cluster analysis

{{#invoke:main|main}} In cluster analysis, the k-medians clustering algorithm provides a way of defining clusters, in which the criterion of maximising the distance between cluster-means that is used in k-means clustering, is replaced by maximising the distance between cluster-medians.

### Median-Median Line

This is a method of robust regression. The idea dates back to Wald in 1940 who suggested dividing a set of bivariate data into two halves depending on the value of the independent parameter ${\displaystyle x}$: a left half with values less than the median and a right half with values greater than the median.[29] He suggested taking the means of the dependent ${\displaystyle y}$ and independent ${\displaystyle x}$ variables of the left and the right halves and estimating the slope of the line joining these two points. The line could then be adjusted to fit the majority of the points in the data set.

Nair and Shrivastava in 1942 suggested a similar idea but instead advocated dividing the sample into three equal parts before calculating the means of the subsamples.[30] Brown and Mood in 1951 proposed the idea of using the medians of two subsamples rather the means.[31] Tukey combined these ideas and recommended dividing the sample into three equal size subsamples and estimating the line based on the medians of the subsamples.[32]

## Median-unbiased estimators

{{#invoke:main|main}} Any mean-unbiased estimator minimizes the risk (expected loss) with respect to the squared-error loss function, as observed by Gauss. A median-unbiased estimator minimizes the risk with respect to the absolute-deviation loss function, as observed by Laplace. Other loss functions are used in statistical theory, particularly in robust statistics.

The theory of median-unbiased estimators was revived by George W. Brown in 1947:[33]

An estimate of a one-dimensional parameter θ will be said to be median-unbiased if, for fixed θ, the median of the distribution of the estimate is at the value θ; i.e., the estimate underestimates just as often as it overestimates. This requirement seems for most purposes to accomplish as much as the mean-unbiased requirement and has the additional property that it is invariant under one-to-one transformation.

—page 584

Further properties of median-unbiased estimators have been reported.[34][35][36][37] In particular, median-unbiased estimators exist in cases where mean-unbiased and maximum-likelihood estimators do not exist. Median-unbiased estimators are invariant under one-to-one transformations.

## History

The idea of the median originated{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }} in Edward Wright's book on navigation (Certaine Errors in Navigation) in 1599 in a section concerning the determination of location with a compass. Wright felt that this value was the most likely to be the correct value in a series of observations. In 1757, Roger Joseph Boscovich developed a regression method based on the L1 norm and therefore implicitly on the median.[38] In 1774, Laplace suggested the median be used as the standard estimator of the value of a posterior pdf. The specific criteria was to minimize the expected magnitude of the error; |α - α*| where α* is the estimate and α is the true value. Laplaces's criterion was generally rejected for 150 years in favor of the least squares method of Gauss and Legendgre which minimizes < (α - α*)2 > to obtain the mean. [39] The distribution of both the sample mean and the sample median were determined by Laplace in the early 1800s.[12][40] Antoine Augustin Cournot in 1843 was the first{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }} to use the term median (valeur médiane) for the value that divides a probability distribution into two equal halves. Gustav Theodor Fechner used the median (Centralwerth) in sociological and psychological phenomena.[41] It had earlier been used only in astronomy and related fields. Gustav Fechner popularized the median into the formal analysis of data, although it had been used previously by Laplace.[41]

Francis Galton used the English term median in 1881,[42] having earlier used the terms middle-most value in 1869 and the medium in 1880.{{ safesubst:#invoke:Unsubst||date=__DATE__ |\$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }}

{{#invoke:Portal|portal}}

## References

1. http://www.stat.psu.edu/old_resources/ClassNotes/ljs_07/sld008.htm Simon, Laura J.; "Descriptive statistics", Statistical Education Resource Kit, Pennsylvania State Department of Statistics
2. {{#invoke:citation/CS1|citation |CitationClass=book }}
3. {{#invoke:citation/CS1|citation |CitationClass=book }}
4. {{#invoke:citation/CS1|citation |CitationClass=book }}
5. http://www.se16.info/hgb/cheb2.htm#3unimodalinequalities
6. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
7. {{#invoke:citation/CS1|citation |CitationClass=book }}
8. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
9. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
10. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
11. {{#invoke:Citation/CS1|citation |CitationClass=journal }} Cite error: Invalid <ref> tag; name "Stigler1973" defined multiple times with different content
12. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
13. {{#invoke:citation/CS1|citation |CitationClass=book }}
14. {{#invoke:citation/CS1|citation |CitationClass=book }}
15. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
16. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
17. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
18. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
19. {{#invoke:citation/CS1|citation |CitationClass=book }}
20. {{#invoke:citation/CS1|citation |CitationClass=book }}
21. Bonett DG, Seier E (2006) Conﬁdence interval for a coeﬃcient of dispersion in non-normal distributions. Biometrical Journal 48 (1) 144-148
22. http://www.iowa.gov/tax/locgov/Statistical_Calculation_Definitions.pdf
23. http://www.tax.ny.gov/research/property/reports/cod/2010mvs/reporttext.htm
24. http://www.state.sd.us/drr2/publications/assess1199.pdf
25. Puri, Madan L.; Sen, Pranab K.; Nonparametric Methods in Multivariate Analysis, John Wiley & Sons, New York, NY, 197l. (Reprinted by Krieger Publishing)
26. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
27. {{#invoke:citation/CS1|citation |CitationClass=book }}
28. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
29. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
30. {{#invoke:citation/CS1|citation |CitationClass=book }}
31. {{#invoke:citation/CS1|citation |CitationClass=book }}
32. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
33. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
34. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
35. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
36. {{#invoke:citation/CS1|citation |CitationClass=book }}
37. {{#invoke:citation/CS1|citation |CitationClass=book }}
38. {{#invoke:citation/CS1|citation |CitationClass=book }}
39. Laplace PS de (1818) Deuxième supplément à la Théorie Analytique des Probabilités, Paris, Courcier
40. Keynes, J.M. (1921) A Treatise on Probability. Pt II Ch XVII §5 (p 201) (2006 reprint, Cosimo Classics, ISBN 9781596055308 : multiple other reprints)
41. Galton F (1881) "Report of the Anthropometric Committee" pp 245-260. Report of the 51st Meeting of the British Association for the Advancement of Science