Median (source code)
= Median
{wiki}
A <median> of a real <random variable> $X$ is a number $m$ with at least half the <probability> at or below it and at least half at or above it:
$$
\mathbb P(X\leq m)\geq\tfrac12,\qquad
\mathbb P(X\geq m)\geq\tfrac12.
$$
Equivalently, its <cumulative distribution function> satisfies $F(m^-)\leq1/2\leq F(m)$. The non-strict inequalities matter for atoms: if $X=0$ <almost surely>, zero is its <median> despite having no <probability> strictly below or strictly above it.
A <median> need not be unique. If zero and one each have <probability> $1/2$, every point in $[0,1]$ is a <median>. The generalized inverse $F^{-1}(1/2)$ selects the <quantile function>[lower median]. For a <continuous function>[continuous] strictly increasing <cumulative distribution function>, the unique <median> solves $F(m)=1/2$.
For a finite data set, the <sample median> measures the middle rather than the <arithmetic mean>[arithmetic average]. The sample $1,2,3,4,100$ has <median> three and <mean> 22; changing 100 to a still larger value leaves its <median> unchanged. With finite <absolute moment>[first absolute moment], <median>[medians] are exactly the minimizers of <absolute loss>[expected absolute loss], giving a decision-theoretic reason for their usefulness.
Back to article page