# Re: [R] distance in kmeans algorithm?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 10 Jul 2006 - 03:44:12 EST

You do realize that Mahalanobis distance is just Euclidean distance on some linear transformation of the variables? So all you need to do is to transform the data you pass to kmeans to 'sphere' the Mahalanobis distance.

The K means *algorithms* do depend on Euclidean distance (e.g. in choosing the cluster centres as the centroids), so your initial question makes little sense. You can of course use the criterion with other distances, but you need to develop other algorithms to do so.

On Sun, 9 Jul 2006, Arnau Mir wrote:

> Hello.
>
> Is it possible to choose the distance in the kmeans algorithm?
>
> I have m vectors of n components and I want to cluster them using kmeans
> algorithm but I want to use the Mahalanobis distance or another distance.
>
> How can I do it in R?
> If I use kmeans, I have no option to choose the distance.
>
> Thanks in advance,
>
> Arnau.

```--
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
```
Received on Mon Jul 10 03:49:07 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 10 Jul 2006 - 06:16:17 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.