Take the derivative of $f(m) = \sum_i | x_i - m |$.
I've been told that derivative of each term is +1 or -1. How do you show that?
Take the derivative of $f(m) = \sum_i | x_i - m |$.
I've been told that derivative of each term is +1 or -1. How do you show that?
Copyright © 2021 JogjaFile Inc.
Recall that $$ |x|=\begin{cases} x & x\ge 0\\ -x & x<0 \end{cases} $$
So $$ \frac{d}{dx}|x|=\begin{cases} 1 & x> 0\\ -1 & x< 0 \end{cases} $$
The only problem is at zero, of course. The derivative is not defined there, and so it must be omitted.
Thus in your particular case, you get $1$ whenever $x_i> m$ and $-1$ whenever $x_i< m$