General Question

LostInParadise's avatar

Is there a simple proof for this?

Asked by LostInParadise (32168points) March 14th, 2012

I saw this problem on Yahoo Answers. It seems that it should be true intuitively, but I have difficulty in proving it.

Given n values of Xi, define f(x) = sum(|Xi – x|)
Show that f(x) is minimal for x = median value of Xi

It is tempting to try to differentiate this, but the absolute value causes difficulties.

I was able to prove this for the special case where x is one of the Xi. I can show that f(X(i+1)) – f(Xi) = (2i – n)(X(i+1) – Xi).

X(i+1) – Xi is always positive and 2i – n is negative for Xi below the median and positive for Xi at or above the median. Even this limited proof took more work than this seems to require. Can you come up with something more general?

Observing members: 0 Composing members: 0

4 Answers

BonusQuestion's avatar

Edit: Never mind. I misread the question. :)

LostInParadise's avatar

Thanks,@BonusQuestion. I eventually came up with a similar proof. I also came up with an intuitive way of looking at it. For x < median, most of the values of |Xi – x| will be Xi – x and not x – Xi. Therefore, as x moves from Xi to X(i+1), the net negative coefficient of x will cause f(x) to decrease. The opposite holds true for x > median. The other thing to realize is that the function is continuous, because Xi – x = x – Xi = 0 for x= Xi.

PhiNotPi's avatar

Here’s my way of visualizing the solution:

Imagine a number line with the n points of Xi plotted on it. The goal of the problem is to find a point of the number line where the sum of the distances to the points in the set is minimal. If you pick a value of x such that 7 points are on the right and 3 points are on the left, then you know that x must be moved to the right (increased). If you were to move the point one unit to the right (assuming you don’t cross over any point in the set) then you would be one unit closer to 7 points and one unit farther away from 3 points. This would make the summed distance decrease by 4 units, so you are headed in the right direction. Hopefully this shows how the best direction to move the point on the number line is towards the side with more points. This would balance out when the number on both sides is equal, which is the median of the set.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther