which it is deleted.

**The median as minimiser of a convex function.**

As has been observed first by Jackson [@Jackson-BAMS21], the median of real numbers can also be defined via an optimisation property.

Let $\mathcal{X}=\{x_1,\ldots,x_N\}$ be a multiset of real numbers $x_1,\ldots,x_N\in\mathbb{R}$. The median of $\mathcal{X}$ is $$\begin{aligned}
\operatorname{med}(\mathcal{X})&:=
\mathop{\operatorname{argmin}}\limits_{\mu\in\mathbb{R}} 
E_{\mathcal{X}}(\mu)\;, &
E_{\mathcal{X}}(\mu)&:=
\sum\limits_{i=1}^N
\lvert \mu-x_i\rvert
\;.
\label{med-E}\end{aligned}$$

In this formulation, the order of real numbers is not explicitly invoked. The objective function $E_{\mathcal{X}}(\mu)$ is a continuous, piecewise linear function with a kink at every data value $\mu=x_i$. For even $N$, there will be a constant segment over the interval formed by the two middle values in the rank order.

Median for Weighted Discrete Data {#ssec-medw}
---------------------------------

The median concept can easily be extended to weighted data. We assume that $\mathcal{X}$ is a countable set of real numbers, on which a positive weight function $w:\mathcal{X}\to\mathbb{R}^+$ is given. We will require $w$ to have unit total weight, i.e., $\sum\nolimits_{x\in\mathcal{X}}w(x)=1$.

**Quantile-based definition.**

We can define the median of weighted data analogously to or .

\[def-medw-lhalf\] Let $\mathcal{X}$ be a countable set of real numbers with a positive weight function $w:\mathcal{X}\to\mathbb{R}^+$ of unit total weight. The median of the weighted set $\mathcal{X}$ is 