R/mahal.R

Defines functions mahal

mahal <- function(q, vc){
  storage <- matrix(NA, nrow(q), nrow(q))
  q <- as.matrix(q)
  # generate a matrix of Mahalanobis distances between all possible pairs
  for(i in 1:nrow(q)){
    
    storage[row(q), i] <- sqrt(mahalanobis(x = q, 
                                           center = q[i, ], 
                                           cov = vc))
  }
  return(storage)
}

Try the blockTools package in your browser

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

blockTools documentation built on Feb. 16, 2023, 7:14 p.m.