# Which groups of results is the closest to a central point?

I'm building an application where a specific location is chosen, multiple services are polled to return results for that specific location and shown on a map.

I have the results from the different sources shown in different colours on the map, so you can get a feel for which results are the "best". In this instance "best" is hard to precisely define, but means which are generally the closest to the starting point.

Because everything is lat/lon, I can then, calculate the distance each one is from the starting point. I was thinking calculating the average of the sum of the squares of the distances, as this would favour those result sets who have the closest points. This might skew otherwise good results that have a just a couple of distant outliers, but it's worth a go.

Are there any good algorithms out there that would help in this situation? I've looked at "clustering" algorithms, but they are good for organising data into groups. However, in this case, I already know what the groups are, I just want to know which group is closest to my target point.

• You seem to be asking for an algorithm to compute sums of squares of distances. Is that really your question?
– whuber
Jan 27 '14 at 18:06
• I can calculate the sum of squares of distances. That seemed sensible to me as a naive solution, but then I thought of the outliers that might skew things. So I thought if I asked nicely here, somebody might have had this problem before and there's a standard approach for comparing result sets around a central point. I just don't want to reinvent the wheel :-) Jan 27 '14 at 18:14
• OK, thanks - so my "prediction" (f) would be always be 0 - ideally, everything would be at the start point, and the true value (y) would be the actual distance from that point? Jan 27 '14 at 18:20
• I see how I can do this now, I'm going to kick the can down the road. Using squares of the deviation will punish outliers, so I'll implement both, see what results both approaches give and see what the rest of the guys think. But it really wasn't that complicated. Thanks Jan 27 '14 at 18:29

$$\text{MAE} = \frac{1}{n}\sum_{i=1}^{n}|e_i|$$
where $|e_i|$ are the distances from the multiple services locations to the point of interest (POI).