Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a population of objects (each of which is described by a list of about a half-dozen real numbers), and I'd like to find some reasonable kind of distance between each of several different test objects and the median of the population, with the goal of being able to say, for example, that because test object A is closer to the median than test object B, therefore A is "more like" the population than B.

I believe that I can use the MultivariateStatistics package to characterize my population, and then either SpatialMedian[] or SimplexMedian[] to find a center. So then I need to find a measure of distance from that center to each test object. I gather that a simple EuclideanDistance would be incorrect, because I need to account for the ellipsoid's size and orientation (I believe, but I'm not certain, that this is the Mahalanobis distance). I don't see a function in the MultivariateStatistics package that lets me find such distances.

Is it possible to compute a meaningful distance from a test object to the median of the population that will let me assert whether one test object is "more like" the population than another, and if so, how do I compute that distance? Practical advice would be much better than theoretical. Thanks!

share|improve this question
Although you refer to a few Mathematica functions it seems the core of your question is not about Mathematica itself, but it is more a statistics-philosophical question. As such, perhaps the statistics SE may be a better place to ask. – Sjoerd C. de Vries Jul 3 '13 at 6:42

Though it's a little hard to tell from your description, you should probably look at the function Nearest which efficiently calculates distances between clusters of points (in any number of dimensions). The function has the option DistanceFunction, which can be one of the built-in ones, or can be defined by the user; hence the Median could be found this way. If you ask a more specific question (perhaps showing some code that you've tried) you are more likely to get more specific replies.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.