R/esova.R

Defines functions esova

Documented in esova

## computes ESOV distance between xnew and x
esova <- function(xnew, x) {
  dm <- dim(x)
  n <- dm[1]    ;    p <- dm[2]
  xnew <- as.matrix(xnew)
  xnew <- matrix(xnew, ncol = p ) ## makes sure xnew is a matrix
  nu <- dim(xnew)[1]
  disa <- matrix(0, n, nu)
  tx <- t(x)

  for (i in 1:nu) {
    xan <- xnew[i, ]
    ma <- 0.5 * ( tx + xan )
    disa[, i] <- colSums( xan * log( xan / ma ) + tx * log( tx/ma ), na.rm = TRUE )
  }

  t(disa)
}

Try the Compositional package in your browser

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

Compositional documentation built on Oct. 9, 2024, 5:10 p.m.