R/dbhatta.R

Defines functions dbhatta

Documented in dbhatta

dbhatta <- function(x){
########## Bhattacharyya distance #######################
# Input:
# x: data matrix
# Output:
# d: bhattacharyya distance matrix
#########################################################
	x <- as.matrix(x)
	n <- dim(x)[1]
	p <- dim(x)[2]
	d <- matrix(0, nrow=n, ncol=n)
	for (i in 1:(n-1)){
	  for (j in (i+1):n){
	    a <- sqrt(x[i,]*x[j,])
	    a <- sum(a)
	    d[i,j] <- acos(a)
	    d[j,i] <- d[i,j]
	  }
	}
	d <- as.dist(d)
	return(d)
}

Try the ICGE package in your browser

Any scripts or data that you put into this service are public.

ICGE documentation built on Oct. 17, 2022, 5:10 p.m.