I'm working with real numbers using modular arithmetic, say in the range $[0,12)$. I would like to calculate some kind of 'modular mean' over a set of values $X$ that minimizes the total error. In other words, the value $\bar{x} \in [0,12)$ such that
$\Sigma_{x \in X} \min(\bar{x}-x \mod N, x-\bar{x} \mod N)$
is minimized.
Using the ordinary mean doesn't quite work. If you consider the clock-face. Then for the values $\{1,3\}$ we get $2$ which is good. But for the values $\{10,1\}$ we get $\frac{11}{2}\mod N = 5.5$. However the value I'm looking for is $11.5$ because this gives an error of
$(11.5-10 \mod N) + (1-11.5 \mod N) = 3$
rather than $5.5$ which gives an error of $11$.
Is there a function/algorithm to find the value of $\bar{x}$? (Assuming the above makes sense!)