# Finding $c,b$ which minimizes $E(|X-c|)$ and $E[(X-b)^2]$

Let $$X$$ be a random variable with support $${1,2,3,5,15,25,50}$$, each point of which has the same probability $$\frac{1}{7}$$. Argue that $$c=5$$ is the value that minimizes $$h(c)=E(|X-c|)$$. Compare $$c$$ with the value of $$b$$ that minimizes $$g(b)=E[(X-b)^{2}]$$.

I am over here: $$h(c)=E(|x-c|)=(|1-c|+|2-c|+|3-c|+|5-c|+|15-c|+|25-c|+|50-c|)\times\frac{1}{7}$$ My main concern is I am not sure using absolute values to argue that 5 is the value that minimizes the equation.

• Do you know any calculus? You can think about it in terms of the derivative with respect to $c$. Jan 21 '20 at 1:20
• I don't have time to write an answer, but it's worth graphing some functions like $|x|$ and $|x|+|x-1|$ or $|x|+|x-1|+|x-3|$ - just smaller sums of absolute values - and seeing that these are just a few line segments pasted end to end - and that you can characterize the slope of that segment by counting how many subtracted terms are greater/less than the current one. Jan 21 '20 at 1:41

Since $$5$$ is the median of the given data set and the weights are all equal to $$\frac 17$$, it minimizes $$E(X-c)$$.