R/rescaledDensities.R

Defines functions rescaledDensities

rescaledDensities <- function(y, a, b, densFunction, probFunction, ...) {
  dens <- ifelse(
    test = (y < a) | (y > b),
    yes  = 0,
    no   = densFunction(y, ...)
  )
  F.a <- tryCatch(probFunction(a, ...), error = function(e) 0)
  F.b <- ifelse(is.infinite(b), 1, probFunction(b, ...))
  dens <- dens / (F.b - F.a)
  attributes(dens) <- attributes(y)
  dens
}

Try the TruncExpFam package in your browser

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

TruncExpFam documentation built on April 11, 2025, 6:11 p.m.