I have the following homework problem.
Let $(x_1,x_2,\ldots,x_n)$ be an increasing sample of size $n$. Show that the function $$f: x\mapsto \sum_{k=1}^n |x_k-x|$$ obtains a global minimum at the median $$x_{1/2}=\begin{cases} x_{(n+1)/2},\qquad & n \text{ odd} \\ 1/2 \left(x_{n/2}+x_{n/2+1}\right),\qquad &n \text{ even}\end{cases}.$$
My attempt
Firstly, since $f$ is not differentiable at $x_1,\ldots,x_n$, so these are all critical points. Also, $$f'(x)=2k-n,\qquad x\in (x_k,x_{k+1}), k=0,1,\ldots,n.$$ Thus, if $n$ is even, then all the points in the interval $(x_{n/2}, x_{n/2+1})$ are also critical points.
In either case, $x_{1/2}$ is a critical point of $f$. Moreover, $f'$ changes sign from negative to positive at $x_{1/2}$. Thus, $x_{1/2}$ is a local minimum of $f$.
How do I show it is also the global minimum?
How do I should it is also the global minimum?
means. – Rodrigo de Azevedo Jan 18 '23 at 16:35