Hi all, I'd like to add the Bhattacharyya method to the dist function. What is the best way to do this? I'm using R 1.9.0 and I was looking for the code that defines the already existing distances, but I didn't manage. As far as I understand, dist is defined in mva that is part of the stats package now, but where is the code? Thank you very much, Giampiero
On Mon, 3 May 2004, Giampiero Salvi wrote:> Hi all, > I'd like to add the Bhattacharyya method to the dist function. > What is the best way to do this? I'm using R 1.9.0 and I was looking > for the code that defines the already existing distances, but I didn't > manage. As far as I understand, dist is defined in mva that is part > of the stats package now, but where is the code?In src/library/stats/src/distance.c Where else did you think the C source code for the stats package would be but src/library/stats/src? You will need to add your own function, and BTW, I don't think `the Bhattacharyya method' is appropriate for dist, as it is defined for distributions, not data items. It's even defined that way in your own paper http://www.speech.kth.se/ctt/publications/papers03/icphs03_giampi.pdf although you make Gaussian assumptions about the distributions whihc you did not in your posting. -- Brian D. Ripley, ripley at 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
>>>>> "Giampiero" == Giampiero Salvi <giampi at speech.kth.se> >>>>> on Mon, 3 May 2004 11:50:38 +0200 (CEST) writes:Giampiero> I'd like to add the Bhattacharyya method to the Giampiero> dist function. What is the best way to do this? Giampiero> I'm using R 1.9.0 and I was looking for the code Giampiero> that defines the already existing distances, but Giampiero> I didn't manage. As far as I understand, dist is Giampiero> defined in mva that is part of the stats package Giampiero> now, but where is the code? All the standard R packages (such as "stats") are in <Rsource>/src/library/ and look very much like usual R packages, [with the exception of the 'base' package that is very special] I.e, in <Rsource>/src/library/stats/R/dist.R <Rsource>/src/library/stats/man/dist.Rd <Rsource>/src/library/stats/src/distance.c are the R source, docu, and C code, respectively. Where you can e.g. take and unpack ftp://stat.ethz.ch/Software/R/R-devel.tar.gz such that the above '<Rsource>' will be 'R-devel' for you. If you do this, please consider contributing the three changed files back to the R project! Giampiero> Thank you very much, Giampiero> Giampiero you're welcome, Martin