Minimize the sum of distances between a sample and two "centers"

53 Views Asked by At

Suppose we have a set of readings $\{X_{i}\}$, each of which is a real number.

What I want is to find 2 numbers, $a$ and $b$, such that

minimize the sum of distances between each $X_{i}$ and whichever is closer to it

$$ \large i.e. \sum_{i}^{ } min(|X_{i}-a|,|X_{i}-b|) $$

Anybody got an idea?