Message-ID: <1257473494.3104.5.camel@vertical>
Date: 2009-11-06T02:11:34Z
From: Nikos Alexandris
Subject: Bhattacharyya distance metric
In-Reply-To: <26221259.post@talk.nabble.com>
On Thu, 2009-11-05 at 12:25 -0800, Diana Garrett wrote:
> I need to use the Bhattacharyya distance metric to determine population
> separation. Has anyone written a Bhattacharyya distance metric function in
> R?
Something like this ( I think it's correct ):
--%<---
DBhat <- function(X1,X2){
# define means
mX1 <- mean(X1)
mX2 <- mean(X2)
# define difference of means
mDiff <- mX1 - mX2
# define cov
cvX1 <- cov(X1)
cvX2 <- cov(X2)
# define halfsum of cv's
p <- (cvX1+cvX2)/2
# the equation
0.125 * t(mDiff) * p^(-1) * mDiff + 0.5 * log10( det(p) /
sqrt( det(cvX1) * det(cvX2) ))
--%<---
A related thread (in grass-stats):
http://www.mail-archive.com/grass-stats at lists.osgeo.org/msg00183.html
Regards, Nikos