# How can I estimate the minimum distance between 2 sets of coordinates?

I am creating stimuli for an experiment. The stimuli consists of 2 distinct sets of 9 points in a 2D plane. Each set of points can be described by 9 pairs of coordinates. (i.e. http://learnmem.cshlp.org/content/5/6/420/F1.expansion)

I would like to estimate the minimum distance between 2 sets (or patterns) of points. (In the example linked above, I would want to estimate the distance between the "prototype" pattern and the "low" pattern.)

So far I have calculated the Pythagorean distance between every point in pattern A and every point in pattern B, for a total of 81 distance measurements. I believe I now need to match up each point in A to exactly one point in B (trying to minimize the total distance between all pairs). After that step, I would then sum the distances between the matched points. However, I do not know how to do this process.I believe there are over 300,000 possible ways to pair up the dots and I do not know how to calculate all of these possibilities in order to select the best one.

It is not critical that I know the exact distance for any two sets, but I need a reliable estimate. I will need to estimate this distance for many pairs of sets, so I would like to find a solution that is possible to perform for many items within a programming tool, such as R or Matlab.

• Have you considered whether your similarity measure should be invariant under isometries? If I understand correctly, you're asking people to judge the similarity of these patterns and the values of the coordinates don't have any meaning up to at least translations, possibly also rotations -- your measure should reflect this; otherwise you'd be introducing artificial dissimilarity that doesn't correspond to any dissimiliarity a person would perceive. – joriki Apr 6 '11 at 4:23
• On a side note, two similar questions have been asked at stackoverflow, stackoverflow.com/questions/3920839/… and stackoverflow.com/questions/5004449/…, without being answered. (That probably doesn't mean there aren't any good answers, just that questions often go unanswered on stackoverflow.) – joriki Apr 6 '11 at 4:25