Deriving the optimum value of a function I have a function $f(t) = \sum_{i=1}^{N} |y_i-t|$.
What will be the optimum value of t that will minimize it. How to derive it?
Similarly what is the optimal value of t which minimizes $f(t) = \sum_{i=1}^{N} |y_i-t|^{\infty}$?
 A: Here's some major hints to get you started:
For the first one, you might want to consider what $f'$ looks like (as a formula) between the sorted data values (it's discontinuous at the data values). How does it behave as you move through the data? Where does it change from below 0 to above 0?
Here's $f$ vs $t$ (the grey vertical bars on top of the x-axis are the data values):

Can you see how to show what will minimize $f$ now?

For the second case, consider $f_k(t) = ( \sum_{i=1}^{n} |y_i-t|^{k} )^{1/k}$ (you would need to argue that $f_k$ and $f$ share an argmin for a given $k$ - that is taking the $1/k$ power doesn't change the location of the minimum. Below (for the same data as above) $f_k$ is plotted for $k = 2,3,5,9,$ and $99$ (the "$k=2$" case is faint dotted grey at the top, the "$k=99$" case is purple near the bottom):

The "$k=2$" case corresponds to least squares, while $k=1$ would be the previous example. As $k$ increases, it's getting 'pointier'. Can you figure where the 'point' is headed, and why? Can you work out $f_k'$? What happens to that as $k$ increases?
