Understanding the computation of the geometric median

In the Wolfram Demonstration Fermat Point for Many Points, it appears that the geometric median is being calculated for an arbitrary set of five manipulable points. How might one extend this demonstration to computing the median of an arbitrary list of points?

-
The linked demonstration covers the cases of 3 to 10 points, so it must give the general algorithm. Did you download the Mathematica notebook giving the code from the demonstration site? – m_goldberg Jun 25 '13 at 6:05

This is modified code of the Demonstration. In this version you add/remove locators by clicking mouse while holding CTRL (command on mac) key. It wroks due to LocatorAutoCreate -> True option. You should check that it makes sense, I am not sure why author have chosen a different implementation.

Manipulate[
Module[{s, d, simp, x, y},
s = Nest[(simp = #; d = Map[Norm[# - simp] &, p];
Total[1/d]) &, Total[p]/Length[p], 10];
Show[{DensityPlot[
Total[Norm[{x, y} - s] & /@ p], {x, -3, 3}, {y, -3, 3},
ColorFunction -> "Aquamarine", Frame -> False, ImageSize -> 500],
Graphics[{Gray, Line[{s, #}] & /@ p, Black, Disk[#, .1] & /@ p,
Red, Disk[s, .05], Orange, Disk[b = Plus @@ p/Length[p], .05],
Style[{
Text["sums of distances", {0, -2.2}, {0, 0}],
Text[
"from Fermat point (red): " <>
ToString[Total[Norm[# - s] & /@ p]], {0, -2.8}, {0, 0}],
Text["from centroid (orange): " <>
ToString[Total[Norm[# - b] & /@ p]], {0, -2.5}, {0, 0}]},
20, Black]}, PlotRange -> 3, ImageSize -> 500]}]],
{{p, Table[1. {Cos[k 2 \[Pi]/11], Sin[k 2 \[Pi]/11]}, {k, 5}]},
Locator, LocatorAutoCreate -> True}]


-
Very nice, thank you! Is there some way I can directly feed a list of points to the function and calculate the coordinates for the red point? – Terry Jun 25 '13 at 2:30
How is the calculation of the geometric median actually being performed here? – Terry Jun 25 '13 at 2:33
@Terry yes, - replace Table[...] with your list of points. – Vitaliy Kaurov Jun 25 '13 at 2:33
@Terry: I think it's Weiszfeld's algorithm run for 10 iterations. – Rahul Jun 25 '13 at 2:45