swh:1:snp:ffdd0a7d2c8ea15ad41d45b3b178f668bd942287
Tip revision: f1782e072e5a1e76db2576bcaf395182b2061e0f authored by Derek Young on 31 October 2006, 00:00:00 UTC
version 0.1.0
version 0.1.0
Tip revision: f1782e0
depth.r
######################################################################
# the following depth function can compute the depth for #
# multi points at one time #
######################################################################
#dyn.load("~fxuan/depth/spherical/sphericaldepth.so")
depth <- function(pts,x,Cx=var(x)){
x=x%*%t(chol(solve(Cx)))
pts=pts%*%t(chol(solve(Cx)))
y <- .Fortran("mudepth",
as.integer(nrow(x)),
as.integer(nrow(pts)),
as.integer(ncol(x)),
as.single(pts),
as.single(x),
as.integer(1:nrow(pts)),
as.single(1:nrow(pts)),
PACKAGE="mixtools")
count <- y[[6]]
n <- nrow(x)
depth <- sqrt(8)*(count-n*(n-1)/4)/sqrt((n*(n-1)))#this is to standardize the depth
depth
}