I want to minimize the following sum $$\sum_{i=1}^N (\frac{1}{2}(1-a)(b_{ki} -x )^2+a| b_{ki} -x |)$$ with respect to $x$ where $a\in [0,1]$.
My idea is to minimize each term in the sum using left and right derivatives. However I cannot make it work.
Can anyone help me get started or give me a hint?
Hint You can sort the $b_i$ so that $b_1\le b_2\le\cdots\le b_N$. You can add $b_0=-\infty$ and $b_{N+1} = +\infty$. On each interval $[b_j, b_{j+1}]$, the functional is a quadratic function of $x$ that is easy to minimize.