patternMinor
Choose a "middle" point from a set
Viewed 0 times
pointchoosemiddlefromset
Problem
I read a post which talks about pretty much the same problem. But here I simplify the problem hoping that a concrete proof can be offered.
There is a set $A$ which contains some discrete points (one-dimensional), like $\{1, 3, 37, 59\}$. I want to pick one point from $A$ which minimizes the sum of distances between this point and others.
There may be lot of posts out there, and my problem is just the one-dimensional version of those. I know how to prove it if $A$ is not discrete, but I fail when $A$ is discrete like above.
Please answer with a concrete proof.
There is a set $A$ which contains some discrete points (one-dimensional), like $\{1, 3, 37, 59\}$. I want to pick one point from $A$ which minimizes the sum of distances between this point and others.
There may be lot of posts out there, and my problem is just the one-dimensional version of those. I know how to prove it if $A$ is not discrete, but I fail when $A$ is discrete like above.
Please answer with a concrete proof.
Solution
For a point $x$, let $d(x)$ be the sum of distances between $x$ and points in $A$. For $x \notin A$, the derivative $d'(x)$ has the nice formula
$$ d'(x) = |\{y \in A : y x\}|. $$
This shows why the median is the best answer when you don't have to select a point from $A$. For a point $x \in A$, $d(x)$ is the same as your objective function, hence the solution is to choose the median. You can find the median in linear time, as described in Wikipedia and various other resources.
$$ d'(x) = |\{y \in A : y x\}|. $$
This shows why the median is the best answer when you don't have to select a point from $A$. For a point $x \in A$, $d(x)$ is the same as your objective function, hence the solution is to choose the median. You can find the median in linear time, as described in Wikipedia and various other resources.
Context
StackExchange Computer Science Q#9435, answer score: 2
Revisions (0)
No revisions yet.