R/getdis.R

Defines functions getdis

Documented in getdis

#' Get distance matrix
#'
#' This function returns the distance matrix using L2 distance.
#'
#' @param y dataset of the pooled data
#' 
#' @return A distance matrix based on the L2 distance.
#' 
#' @export
#' 
#' @examples
#' data(example0)
#' data = as.matrix(example0$data)     # pooled dataset
#' getdis(data)
#' 
getdis <- function(y){ #L2 distance
  n = dim(y)[1]
  G = y%*%t(y)
  g = diag(G)
  dis = sqrt( matrix(rep(g,n),n) + matrix(rep(g,n),n,byrow=T) - 2*G )
  dis
}

Try the rgTest package in your browser

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

rgTest documentation built on Aug. 14, 2023, 5:08 p.m.