File: pjt.R

package info (click to toggle)
r-cran-ksamples 1.2-10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 456 kB
  • sloc: ansic: 1,321; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 429 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pjt <- function (x, nn) 
{
    dist <- Harding(nn)
    if (is.nan(dist[1])) 
        stop("can't compute due to numerical instability\n")
    nn <- sort(as.integer(nn))
    nvec <- rev(cumsum(rev(nn)))
    k <- length(nn)
    L <- sum(nn[1:(k - 1)] * nvec[2:k])
    dist <- cumsum(dist)
    x <- floor(x)
    pos <- match(x, 0:L)
    d <- numeric(length(x))
    d[x > L] <- 1
    d[!is.na(pos)] <- dist[pos[!is.na(pos)]]
    d
}