R/step_cdf.R

#'@export
step_cdf <- function(x, start, stop, p){
    ix <- which(start < x &  stop <= x)
    c <- sum(p[ix])
    if(any(start <x &  stop > x)){
       if(sum(start <x &  stop > x) > 1) stop("error")
       ix <- which(start <x &  stop > x)
       prop <- (x-start[ix])/(stop[ix]-start[ix])
       c <- c + p[ix]*prop
    }
    return(c)
}
jean997/sherlockAsh documentation built on May 18, 2019, 11:45 p.m.