# Median of a set with even number of elements

Consider the following sample of numbers: 9,18,11,14,15,17,10,69,11,13 Since there are 10 elements, the median of the set would be (13+14)/2 = 13.5 However, is it wrong to say that median is one of 13 or 14? Can you cite credible sources/authors who claim that 13 or 14 can be the median, i.e. n/2 or (n/2+1)th element can be the median?

• Classically, the answer is anything that minimizes the L1 norm, as people explain here. If you want to make the answer unique, see my answer and my question and my comment. Commented Feb 21 at 6:48
• The two middlemost values if the number of values is even are naturally called comedians (a remark due independently to Stephen Stigler and Roger Koenker). Taking their mean to be the median is explained to non-mathematicians as a rule and to mathematicians as a convention, which as explained in answers, does occasionally bite. Commented Feb 23 at 15:57
• @NickCox: See my answer at stats.stackexchange.com/a/165264/11887 for another use of comedian ... Commented Feb 27 at 3:29
• @kjetil b halvorsen Thanks for the reference. The meaning is different, but the term is aprt/ Commented Feb 27 at 7:58

Another way to define a sample median is as a minimizer of the sum of $$\ell_1$$ distances between a given quantity and each datapoint:

$$m \in \mathcal{O}=\underset{x\in\mathbb{R}}{\textrm{argmin}} \sum_{i=1}^N |x_i - x|$$

It is easy to see that if $$N$$ is even, the set of minimizers $$\mathcal{O}$$ is given by the closed interval $$[x_{(\frac{N}{2})}, x_{(\frac{N}{2}+1)}]$$ where $$x_{(i)}$$ gives the i'th order statistic.

From this perspective, the $$\frac{N}{2}$$ or $$\frac{N}{2}+1$$th value are just as valid as their midpoint, or any other convex combination thereof, as they will all have identical empirical loss.

• Of course, this is Henry's answer in disguise, since the one is the solution to the other.
– usul
Commented Feb 21 at 1:41
• +1. For an intuitive explanation of this, see Hanley et al., (2001, The American Statistician), discussed in this thread. Commented Feb 21 at 7:06

If your definition of the median $$m$$ of a finite multiset of real numbers is that it has the property that half the values are at the median or below and half the values are at the median or above, i.e. (using $$|\{\cdots\}|$$ to mean the count of a set):

$$\Big|\{x_i:x_i \le m\}\Big| \ge \tfrac12 \Big|\{x_i\}\Big| \text{ and } \Big|\{x_i:x_i \ge m\}\Big| \ge \tfrac12 \Big|\{x_i\}\Big|$$

then in your example, any $$m$$ from $$13$$ through to $$14$$ satisfies this condition, i.e. $$m \in [13,14]$$. You might call the numbers in this interval the medians of the data.

The corresponding condition for the distribution of a random variable is $$\mathbb P(X \le m) \ge \frac12 \text{ and } \mathbb P(X \ge m) \ge \frac12$$ which may again produce an interval.

The advantage of using $$13.5$$ is that it is a single value in the middle of the interval. But it has a disadvantage that monotonic transformations can then affect the median in an undesirable way: if you looked for the median of the cubes of your data, then any value in $$[13^3,14^3]=[2197,2744]$$ would satisfy the median condition; however, even though $$13.5^3=2460.375$$ would be in that interval, the midpoint would be the higher $$2470.5$$.

There are arguments to be made for multiple different definitions of empirical quantiles (including the empirical median). The go-to resource for this is Hyndman & Fan, 1996, "Sample Quantiles in Statistical Packages", The American Statistician. R implements all nine of their proposed possibilities, with type=7 being the default.

The R help page ?quantile also points us to this blog post: https://blogs.sas.com/content/iml/2017/05/24/definitions-sample-quantiles.html

• None of the nine types gives 14 in this example, but types 1,3, and 4 all give 13. Commented Feb 20 at 20:52